子系统的特点
instanceof 操作符
Animal类是Dog的直接父类,Creature类和Object类是Dog的间接父类,因此
Dog dog=new Dog(); System.out.println(dog instanceof Dog); //打印true System.out.println(dog instanceof Animal); //打印true System.out.println(dog instanceof Creature); //打印true System.out.println(dog instanceof Object); //打印true //instanceof 右边的操作元也可以是接口名 interface interfaceEx(); class A implements InterfaceEx(); class B extends A(); //对于以下代码,打印true B b=new B(); System.out.printIn(b instanceof InterfaceEx); 打印true
Java语言各种操作符