Sunday, January 1, 2012

Reflect Concept (Display all methods in a class including inherited class methods)


import java.lang.reflect.Method;
public class Reflect
{
public static void main(String args[])
{
CarB ob1=new CarB();
    Class c1=ob1.getClass();
    Method[] meths=c1.getMethods();
    for(Method m:meths)
    {
      System.out.println(m.getName());
    }
}
}

Note:  public class CarB extends Automobile implements IVehicle,IBox

output:

It displays all the methods in CarB, Automobile class

No comments:

Post a Comment