Java The Complete Reference, Seventh Edition

(Greg DeLong) #1

416 Part II: The Java Library


Method Description
Annotation[ ] getAnnotations( ) Obtains all annotations associated with the invoking
object and stores them in an array ofAnnotation
objects. Returns a reference to this array.
Class<?>[ ] getClasses( ) Returns aClassobject for each of the public classes
and inter faces that are members of the invoking
object.
ClassLoader getClassLoader( ) Returns theClassLoaderobject that loaded the class
or inter face used to instantiate the invoking object.
Constructor<T>
getConstructor(Class<?> ...paramTypes)
throws NoSuchMethodException,
SecurityException

Returns aConstructorobject that represents the
constructor for the invoking object that has the
parameter types specified byparamTypes.

Constructor<?>[ ] getConstructors( )
throws SecurityException

Obtains aConstructorobject for each public
constructor of the invoking object and stores them
in an array. Returns a reference to this array.
Annotation[ ] getDeclaredAnnotations( ) Obtains anAnnotationobject for all the annotations
that are declared by the invoking object and stores
them in an array. Returns a reference to this array.
(Inherited annotations are ignored.)
Constructor<?>[ ] getDeclaredConstructors( )
throws SecurityException

Obtains aConstructorobject for each constructor
declared by the invoking object and stores them in
an array. Returns a reference to this array.
(Superclass constructors are ignored.)
Field[ ] getDeclaredFields( )
throws SecurityException

Obtains aFieldobject for each field declared by
this class and stores them in an array. Returns a
reference to this array. (Inherited fields are ignored.)
Method[ ] getDeclaredMethods( )
throws SecurityException

Obtains aMethodobject for each method declared
by this class or inter face and stores them in an
array. Returns a reference to this array. (Inherited
methods are ignored.)
Field getField(StringfieldName)
throws NoSuchMethodException,
SecurityException

Returns aFieldobject that represents the field
specified byfieldNamefor the invoking object.

Field[ ] getFields( )
throws SecurityException

Obtains aFieldobject for each public field of the
invoking object and stores them in an array. Returns
a reference to this array.
Class<?>[ ] getInter faces( ) When invoked on an object, this method returns
an array of the inter faces implemented by the class
type of the object. When invoked on an inter face,
this method returns an array of inter faces extended
by the inter face.

TABLE 16-15 A Sampling of Methods Defined byClass(continued)
Free download pdf