Java Reflection – Invoking Method at Runtime.

Using Java Reflection we can inspect and invoke methods at runtime. This is achieved using a class named java.lang.reflect.Method.

There are basically three steps involved in invoking a method using reflection.

  1. Create a instance of the given class
  2. Prepare the parameters to invoke the method
  3. Invoke method using the java.lang.reflect.Method

Create a instance of the given class.

Prepare the parameters to invoke the method.

Invoke method using the java.lang.reflect.Method.

Complete Example Code

One thought on “Java Reflection – Invoking Method at Runtime.

Leave a comment

Your email address will not be published. Required fields are marked *