二元操作符,当左边的对象是右边类或子类所创建对象时,返回true;否则,返回false。
class A {
}
class B extends A {
}
public class Test {
public static void main(String[] args) {
A a = new A();
B b = new B();
System.out.println(a instanceof B);// false
System.out.println(a instanceof A);// true
System.out.println(b instanceof A);// true
}
}