Mega Code Archive

 
Categories / Java Book / 008 Reflection
 

0418 Get fields, methods and classes

Field getDeclaredField(String name) Returns a Field object that reflects the specified declared field of the class or interface represented by this Class object. Field[] getDeclaredFields() Returns an array of Field objects reflecting all the fields declared by the class or interface represented by this Class object. Method getDeclaredMethod(String name, Class<?>... parameterTypes) Returns a Method object that reflects the specified declared method of the class or interface represented by this Class object. Method[] getDeclaredMethods() Returns an array of Method objects reflecting all the methods declared by the class or interface represented by this Class object. Class<?> getDeclaringClass() If the class or interface represented by this Class object is a member of another class, returns the Class object representing the class in which it was declared. Class<?> getEnclosingClass() Returns the immediately enclosing class of the underlying class. Method getMethod(String name, Class<?>... parameterTypes) Returns a Method object that reflects the specified public member method of the class or interface represented by this Class object. Method[] getMethods() Returns an array containing Method objects reflecting all the public member methods of the class or interface represented by this Class object, including those declared by the class or interface and those inherited from superclasses and superinterfaces.