Java 操作符

子系统的特点

 

 

 

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语言各种操作符

 

posted @ 2016-10-12 14:40  时间&煮雨  阅读(139)  评论(0编辑  收藏  举报