img
Method
Description
Method getMethod(String methName,
Returns a Method object that represents the
Class<?> ... paramTypes) method specified by methName and having the
throws NoSuchMethodException,
parameter types specified by paramTypes.
SecurityException
Method[ ] getMethods( )
Obtains a Method object for each public method
throws SecurityException
of the invoking object and stores them in an array.
Returns a reference to this array.
String getName( )
Returns the complete name of the class or
inter face of the invoking object.
ProtectionDomain getProtectionDomain( )
Returns the protection domain associated with the
invoking object.
Class<? super T> getSuperclass( )
Returns the superclass of the invoking object. The
return value is null if the invoking object is of type
Object.
boolean isInter face( )
Returns true if the invoking object is an inter face.
Other wise, it returns false.
T newInstance( )
Creates a new instance (i.e., a new object) that is
throws IllegalAccessException,
of the same type as the invoking object. This is
InstantiationException
equivalent to using new with the class' default
constructor. The new object is returned.
String toString( )
Returns the string representation of the invoking
object or inter face.
TABLE 16-15
A Sampling of Methods Defined by Class (continued)
The methods defined by Class are often useful in situations where run-time type
information about an object is required. As Table 16-15 shows, methods are provided that
allow you to determine additional information about a particular class, such as its public
constructors, fields, and methods. Among other things, this is important for the Java Beans
functionality, which is discussed later in this topic.
The following program demonstrates getClass( ) (inherited from Object) and
getSuperclass( ) (from Class):
// Demonstrate Run-Time Type Information.
class X {
int a;
float b;
}
class Y extends X {
double c;
}
class RTTI {
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home