Reflection
- Class getSuperclass()
- Class[] getInterfaces()
- Package getPackage()
- Field[] getDeclaredFields()
- Constructor[] getDeclaredConstructors()
- Method[] getDeclaredMethods()
Example: Enumerating static fields Math class
Field[] fields = Math.class.getDeclaredFields();
for (int i = 0; i < fields.length; i++)
if (Modifier.isStatic(fields[i].getModifiers()))
System.out.println(fields[i].getName());
previous |
start |
next .... [Slide 42] ....