tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Commons Lang3 > Classes > Get All Super Classes

Get All Super Classes 

Apache Commons Lang 3.0 is a java library with lot of utilities and reusable components. This requires the library commons-lang3-3.0.1.jar to be in classpath. The following example shows using ClassUtils.getAllSuperclasses() API. It returns the list of all super classes of the given class.

File Name  :  
com/bethecoder/tutorials/commons_lang/tests/classes/GetSuperClassesTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.commons_lang.tests.classes;

import java.util.Hashtable;
import java.util.List;
import java.util.Stack;
import java.util.Vector;

import org.apache.commons.lang3.ClassUtils;

public class GetSuperClassesTest {

  /**
   @param args
   */
  public static void main(String[] args) {
    List<Class<?>> superClasses = ClassUtils.getAllSuperclasses(Vector.class);
    System.out.println(superClasses);
    
    superClasses = ClassUtils.getAllSuperclasses(Hashtable.class);
    System.out.println(superClasses);

    superClasses = ClassUtils.getAllSuperclasses(Stack.class);
    System.out.println(superClasses);

  }
}
   

It gives the following output,
[class java.util.AbstractList, class java.util.AbstractCollection, 
	class java.lang.Object]

[class java.util.Dictionary, class java.lang.Object]

[class java.util.Vector, class java.util.AbstractList, 
	class java.util.AbstractCollection, class java.lang.Object]



 
  


  
bl  br