Java Reflection class get inheritance hierarchy

Description

Java Reflection class get inheritance hierarchy

public class Main {
   public static void main(String args[]) throws Exception {
      Class c = Class.forName("javax.swing.JLabel");
      print(c.getSuperclass());//w w w  .  j  ava2s.c  o  m
      System.out.print(c);
   }

   static void print(Class<?> c) {
      if (c != null) {
         print(c.getSuperclass());
         System.out.println(c + "<--");
      }
   }
}



PreviousNext

Related