When do I need to use reflection feature in Java? Reflection feature in java allows an executing java program for introspecting upon itself. It also allows for manipulating internal properties of the program. For instance, it is possible to obtain the names of all members of a Java class and displaying them, using reflection feature. It reflects the classes, objects and interfaces in the concurrent JVM. This API can be used for writing certain developing tools such as debuggers, class browsers, and GUI builders.
The following are the operations which can be done by reflection feature:
- Determine the class of the object - Finding the methods declaration, constants of an interface. - Creating an instance of a class without knowing the name until runtime - Values of an object’s fields can get and set, even the field name is not known.
|