Java tutorial
public class Main { public static void main(String[] args) throws Exception { Main cls = new Main(); Main subcls = new SubClass1(); // class Main Class c = cls.getClass(); System.out.println(c); // sub class SubClass1 Class c1 = subcls.getClass(); System.out.println(c1); // represent a subclass of the specified class object Class retval = c1.asSubclass(c); System.out.println(retval); } } class SubClass1 extends Main { // sub class }