Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { public static List<Class<?>> getSuperClasss(Class<?> sourceClass, boolean isAddCurrentClass) { List<Class<?>> classList = new ArrayList<Class<?>>(); Class<?> classs; if (isAddCurrentClass) { classs = sourceClass; } else { classs = sourceClass.getSuperclass(); } while (classs != null) { classList.add(classs); classs = classs.getSuperclass(); } return classList; } }