public class Test {
public static void main(String[] args) {
System.out.println(A.class.isAssignableFrom(A.class));
System.out.println(B.class.isAssignableFrom(A.class));
System.out.println(C.class.isAssignableFrom(A.class));
System.out.println(D.class.isAssignableFrom(A.class));
System.out.println(E.class.isAssignableFrom(A.class));
System.out.println(F.class.isAssignableFrom(A.class));
}
}
class A extends B implements E,F{
}
class B{
}
class C{
}
class D{
}
interface E{
}
interface F{
}
判断前者是不是后者的父类,实现的接口或者类本身。
java_isAssignableFrom
最新推荐文章于 2023-05-11 14:21:36 发布