获取所有超类作为数组
/* 来自 nowjava - 时代Java*/ import java.lang.reflect.Array; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.URL; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; public class Main{ public static void main(String[] argv) throws Exception{ Class clazz = String.class; System.out.println(java.util.Arrays.toString(getAllSuperclassesAsArray(clazz))); }/*from n o w j a v a . c o m - 时 代 Java*/ public static Class<?>[] getAllSuperclassesAsArray(Class<?> clazz) { if (clazz == null) { return null; } List<Class<?>> classes = CollectionUtil.createArrayList(); Class<?> superclass = clazz.getSuperclass(); while (superclass != null