Java reflection tutorial with examples

Dictionary meaning of reflection: The throwing back by a body or surface of light, heat, or sound without absorbing it.

Java reflection is an API which is used to express code which is able to inspect other code in the same system. It provides the ability to inspect classes, interfaces, fields and methods at runtime, without knowing much about them at compile time. We can modify the runtime behavior of application using reflection. Refection can be used to instantiate new objects, invoke its methods and get or set field values using reflection.

The java.lang and java.lang.reflect packages provide classes for java reflection.

Java reflection tutorial

Content Protection by
Please Share