Reflection is a process that provide the ability to inspect and modify the
runtime behavior of applications. Using reflection we can inspect a
class,interface, enums, get their structure, methods and fields information at
runtime even though class is not accessible at compile time. We can also use
reflection to instantiate an object, invoke it’s methods, change field values.
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.
The java.lang.Class class performs mainly two tasks:
1 provides methods to get the metadata of a class at run time.
2 provides methods to examine and change the run time behavior of a class.
Used of Reflection:The Reflection API is mainly used in
1 IDE (Integrated Development Environment) e.g. Eclipse, MyEclipse, NetBeans
etc.
2 Debugger
3 Test Tools etc.