Java Reflection Introduction
What you need to know before this learning.
- You should have learned and understood everything under Java Basic.
About handling unknown objects at runtime.
The Java Reflection API allows programs to find out everything about an object at runtime.
- Java is a dynamic language and Java Reflection enables a Java class can be instantiated and loaded up, after a program has started.
- When the instantiated object is ready, you can through the Java Reflection, perform methods that the object is implemented with.
- In short, Java Reflection API gives developers a window in what the JVM knows about Java objects.
- One can also say that this is all about behind the scene programming.
Fetch information about classes with the Class type object
The Reflection API is defined by the
java.lang.Class class, and the classes and interfaces of the
With reflection, you can:
- identify the type of en object,
- which class it extends,
- which interfaces it implements,
- and which modifiers, such as public of final, apply to the class
You can query for:
- the constructors,
- methods and data members of a class,
- and their modifiers.
- You can instantiate a class without knowing its name at build time.
- You can invoke methods and access data members of an object dynamically.
- With reflection, you can:
Used to develop tools
Reflection is primarily used by developers of tools, such as GUI design tools or debuggers.
- You can use a Method object like a type-safe function pointer, but it may be better to design your calls to work with interfaces.
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the
correctness in the pages or source codes.
The risk of using this web-site pages or any program
codes from this website is entirely at the individual user.