Reflection API
Reflection makes it possible to inspect the classes, interfaces,
fields and methods at run time without knowing the names of the classes and
also possible to instantiate the object, calling methods and get/set the field
variables.
EX:
1.
Method[] meds = Employee.class.getDeclaredMethods();
2.
Method[] med = Employee.class.getMethods();
In the above statements first statement return all the public, private,
protected and default methods of the Employee Class
Second statement returns the All public methods of super and Employee
class.
DummyClass dummy
= new DummyClass();
System.out.println("Class
Name:" + ReflectionUtils.getClassName(dummy));
System.out.println("Modifier:" + ReflectionUtils.getModifier(dummy));
No comments:
Post a Comment