Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { /** * Returns an array of the superclasses of cls. * * @return java.lang.Class[] * @param cls * java.lang.Class */ //start extract getSuperclasses public static Class[] getSuperclasses(Class cls) { int i = 0; for (Class x = cls.getSuperclass(); x != null; x = x.getSuperclass()) i++; Class[] result = new Class[i]; i = 0; for (Class x = cls.getSuperclass(); x != null; x = x.getSuperclass()) result[i++] = x; return result; } }