//package com.nowjava;/*来自 N o w J a v a . c o m*/
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Main {
public static void main(String[] argv) throws Exception {
Class clazz = String.class;
System.out.println(java.util.Arrays
.toString(getInheritanceHierarchy(clazz)));
}
/**
n o w j a v a . c o m - 时代Java 提供
**/
/**
* Returns the inheritance hierarchy of the specified class.
* The returned array includes all superclasses of the specified class
* starting with the most general superclass, which is
* <code>java.lang.Object</code>. The returned array also
* includes the class itself as the last element. Implemented
* interfaces are not included.
* @param clazz the Class
* @return all superclasses, most general superclass first
*/
public static Class[] getInheritanceHierarchy(Class clazz) {
List classes = new ArrayList();
Class currentClass = clazz;
while (null != currentClass) {
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。