Java Reflection API
Java Reflection is
a process of examining or
modifying the run time
behavior of a class at run time.
The java.lang.Class class
provides many methods that can be used to get metadata, examine and change the
run time behavior of a class.The
java.lang and java.lang.reflect packages provide classes for java reflection.
Fig: Java Reflection API |
Where it is used
The
Reflection API is mainly used in:
- IDE (Integrated Development
Environment) e.g. Eclipse, MyEclipse, NetBeans etc.
- Debugger
- Test Tools etc.
Example of Reflection API in java
class Simple{}
class Test{
public static void main(String args[]){
Class c=Class.forName("Simple");
System.out.println(c.getName());
}
}
Output:
simple
No comments:
Post a Comment