5
比方说,我有两个Class
对象。有没有办法来检查一个类是否是另一个类的子类?检查Class对象是否是Java中另一个Class对象的子类型?
public class Class1 { ... }
public class Class2 extends Class1 { ... }
public class Main {
Class<?> clazz1 = Class1.class;
Class<?> clazz2 = Class2.class;
// If clazz2 is a subtype of clazz1, do something.
}
您是否在寻找:http://stackoverflow.com/questions/3504870/how-to-test-if-one-java-class-extends-another特技的运行时间 – JRaymond 2012-04-27 05:12:50