How to get the Methods Information of a class using Reflection


We can access the methods of a class Object
Method[] method = aClass.getMethods();
Methods are covered in more detail in the text on Methods.


import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
public class  ReflectionExample {
 public static void main(String[] args) {
  Date date = new Date();
  Class objCass = ArrayList.class;
  Method[] methods = objCass.getMethods();
  for (Method method : methods) {
   System.out.println("************************");
   System.out.println("Method Name : " + method.getName());
   System.out.println("Method Parameters types : "
     + method.getParameterTypes());
   System.out.println("Method return types : "
     + method.getReturnType());
  }
 }
}



Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email