Reflection API Tutorials and Examples

In this section you will learn about Reflection API and all of its methods. Reflection API is a powerful technique (that provides the facility) to find-out its environment as well as to inspect the class itself.

Reflection API Tutorials and Examples

In this section you will learn about Reflection API and all of its methods. Reflection API is a powerful technique (that provides the facility) to find-out its environment as well as to inspect the class itself.

Reflection API Tutorials and Examples

Reflection API Tutorials and Examples

     

In this section we are giving tutorials about Reflection framework in Java. The Reflection API of Java programming language is very powerful and can be used to find the information about the environment in which application is running.

Reflection framework was introduced in the Java 1.1 since then it is evolved to provide many new features.

Here are articles and examples of Java Reflection framework.

  1. Reflection API : A Brief Introduction
    In this section you will learn about Reflection API and all of its methods.
    Reflection API is a powerful technique (that provides the facility) to find-out its environment as well as to inspect the class itself. Reflection API was included in Java 1.1.

    Here we are providing few of the examples to give a better overview of the Reflection API :

  2. Getting the implemented Interfaces
    In this section you will learn how to retrieve an Interface (that included in the program) by using the getInterfaces() method. Here is an example that provides the usage of the getInterfaces() method in more detail. 

  3. Retrieving the class name through Reflection API
    A more generic way, how to retrieve the name of the class (that is used in the program) that reflects the package name by using the getName() method. Here is an example that provides the proper way to use the getName() method.

  4. Finding out the superclass name of the Class
    Here we show you the way to find out the Superclass name by using the getSuperclass() method. The given example demonstrates the use of getSuperclass() method in more detail.

  5. Getting the method name used in the Application
    In this section we describe how to retrieve method name by using the getMethods() method. Here is an example that demonstrates the use of the getMethods() method in more detail.

  6. Finding out the object of the Class
    This section illustrates how to retrieve an object name that reflects the package name by using the object.getClass() method. Here is an example that provides the proper usage of the object.getClass() method in more detail.

  7. Finding out the class fields
    This section explores you, how to retrieve the fields of the class by using the getFields() method. For this we are taking an example that provides the use of the getFields() method in detailed way.

  8. Getting information about Constructor
    In this section you will learn, how to retrieve the information about the constructor by using the getConstructors() method. Here is an example that provides the usage of the getConstructors() method.

  9. No Argument Constructor Example
    In this section you will learn how to know that whether any class consists No-Argument Constructor or not ?. Here is an example that provides the usage of the newInstance() method in more detail.

  10. Getting Methods Information of a class
    In this part of tutorial you will learn how to retrieve information of all methods of a class (that included in the program) by using the getMethods() method. Here is an example that provides the usage of the getMethods() method in more detail.

  11. Identifying array using Reflection
    In this section we will describe you how to identify the object is Array or not ? with the use of boolean method isArray(). Here is an example that demonstrates the use of the isArray() method for identification of Array object.

  12. Getting Fields Information of a class
    In this section of "Reflection Tutorial" you will know how to retrieve the  specific field of any class by using the getField() method. For this we are taking an example that provides the use of the getField() method in detailed way.

  13. Getting Component type
    In this section you will come to know that how you can retrieve Component Type of an array's element. The component type of an Array is the type of array's element.

  14. Examine Interface Example
    In this part of tutorial we will discuss how do you know that whether a given class is an "Interface" or a "Class"

  15. Class Modifier Example
    In this section you will learn how to retrieve modifier's information of a class that we have taken in our program.

  16. Calling ( Invoking ) Methods through Reflection
    In previous sections we have seen that how we can use "Reflection" to get information related to any Method. Now in this section of the tutorial you will come to know that we can also call methods of a class with the help of "Reflection"

  17. Setting Fields Information of a class using Reflection
    As in our previous example we have seen that we can get field values of a class by using the Field class. Now we can also set different field values of that class by using set() method.