Getting name of superclass is easy. Consider the following code sample:
System.out.println("Super class of RuntimeException is: " +
ArithmeticException.class.getSuperclass());
System.out.println("Super class of " +
ArithmeticException.class.getSuperclass()+ " is: "
+ ArithmeticException.class.getSuperclass().getSuperclass());
System.out.println("Super class of " +
ArithmeticException.class.getSuperclass().getSuperclass()+ " is:
"+ArithmeticException.class.getSuperclass().getSuperclass().getSuperclass());
System.out.println("Super class of " +
ArithmeticException.class.getSuperclass().getSuperclass().getSuperclass()+ " is:
"+ArithmeticException.class.getSuperclass().getSuperclass().getSuperclass().
getSuperclass());
Output:
Super class of RuntimeException is: class java.lang.RuntimeException
Super class of class java.lang.RuntimeException is: class java.lang.Exception
Super class of class java.lang.Exception is: class java.lang.Throwable
Super class of class java.lang.Throwable is: class java.lang.Object