Java tutorial
//package com.java2s; import java.util.Collection; public class Main { private static void _addSuperTypes(Class<?> cls, Class<?> endBefore, Collection<Class<?>> result, boolean addClassItself) { if (cls != endBefore && cls != null && cls != Object.class) { if (addClassItself) { if (!result.contains(cls)) { result.add(cls); } else { return; } } for (Class<?> intCls : cls.getInterfaces()) { _addSuperTypes(intCls, endBefore, result, true); } _addSuperTypes(cls.getSuperclass(), endBefore, result, true); } } }