Java Reflection API Tutorial

This is a complete beginner to expert in-depth Java Reflection API Tutorial. Reflection is commonly used by programs which require the ability to examine or modify the runtime behavior of applications running in the Java virtual machine. This is a relatively advanced feature and should be used only by developers who have a strong grasp of the fundamentals of the language.

The source code examples of this tutorial are well tested with our local development environment and you can use these code examples as bug-free. The complete core java reference guide available on Core Java Guide.

In this article, we will discuss Java Class and it's methods which entry point for all the reflection operations For every type of object, JVM instantiates an immutable instance of java.lang.Class that provides methods to examine the runtime properties of the object and create new objects, invoke its method and get/set object fields.

A Constructor is used in the creation of an object that is an instance of a class. Typically it performs operations required to initialize the class before methods are invoked or fields are accessed. Constructors are never inherited.

This article describes how to determine if a class member is a field of array type, illustrates how to create new instances of arrays with simple and complex component types and shows how to access fields of type array and individually access array elements with examples.