标签:ati strong eof over test AC void ide object
class1.isAssignableFrom(class2) :class2是不是class1的子类或者子接口
o instanceof TypeName:用来判断一个对象实例 o 是否是一个类或接口(TypeName)的或其子类子接口的实例
public class Test { public static void main(String[] args) { People it=new IT(); System.out.println(People.class.isAssignableFrom(it.getClass())); System.out.println(Object.class.isAssignableFrom(it.getClass())); } } interface People { void eat(); } class IT implements People{ @Override public void eat() { } }
结果:
true true
Class.isAssignableFrom(Class clz)方法 与 instanceof 关键字的区别
标签:ati strong eof over test AC void ide object
原文地址:https://www.cnblogs.com/xiaoliangup/p/9157807.html