instanceof
来源:互联网 发布:java迭代器的使用 编辑:程序博客网 时间:2024/06/07 09:50
public interface A {}
/** * * @author thinkpad * Description :父类,实现接口A */public class B implements A{}
/** * * @author thinkpad * Description :子类,继承B */public class C extends B{}
public class InstanceTest { @Testpublic void testBestPractice() {A ab = new B(); A ac = new C(); B bb = new B(); B bc = new C(); C cc = new C(); //..instanceof A System.out.println("ab instanceof A = " + (ab instanceof A));//ab instanceof A = true System.out.println("ac instanceof A = " + (ac instanceof A));//ac instanceof A = true System.out.println("bb instanceof A = " + (bb instanceof A));//bb instanceof A = true System.out.println("bc instanceof A = " + (bc instanceof A));//bc instanceof A = true System.out.println("cc instanceof A = " + (cc instanceof A));//cc instanceof A = true System.out.println("null instanceof A = " + (null instanceof A));//null instanceof A = false System.out.println("-------------------------------------");// //..instanceof B System.out.println("ab instanceof B = " + (ab instanceof B));//ab instanceof B = true System.out.println("ac instanceof B = " + (ac instanceof B));//ac instanceof B = true System.out.println("bb instanceof B = " + (bb instanceof B));//bb instanceof B = true System.out.println("bc instanceof B = " + (bc instanceof B));//bc instanceof B = true System.out.println("cc instanceof B = " + (cc instanceof B));//cc instanceof B = true System.out.println("null instanceof B = " + (null instanceof B));//null instanceof B = false System.out.println("-------------------------------------"); //..instanceof C System.out.println("ab instanceof C = " + (ab instanceof C));//ab instanceof C = false System.out.println("ac instanceof C = " + (ac instanceof C));//ac instanceof C = true System.out.println("bb instanceof C = " + (bb instanceof C));//bb instanceof C = false System.out.println("bc instanceof C = " + (bc instanceof C));//bc instanceof C = true System.out.println("cc instanceof C = " + (cc instanceof C));//cc instanceof C = true System.out.println("null instanceof C = " + (null instanceof C));//null instanceof C = false System.out.println("-------------------------------------");// }}
0 0
- instanceof?
- instanceof
- instanceof
- instanceof
- instanceof
- instanceof
- instanceof
- instanceof
- instanceof
- instanceof
- instanceof
- instanceof
- instanceof
- instanceof
- instanceof
- instanceof
- instanceof
- instanceof
- uva 502(模拟)
- oracle db中,某一种数据字典pct miss的计算公式
- lightoj 1240 计算机图论(计算三维点到线段的距离)
- SSH启动异常: java.lang.NoClassDefFoundError: javax/el/ExpressionFactory
- lombok配置问题
- instanceof
- The difference between register(寄存器), latch(锁存器) and flip-flop(触发器)
- HDU 1047 Integer Inquiry 大数相加 string解法
- http://www.doudoutxt.com/files/article/51465/728de201.html
- http://www.doudoutxt.com/files/article/51465/759z992.html
- List 的排序,重载greater<>实现
- 黑马程序员21——交通灯管理系统
- 冒泡法排序(汇编语言)
- http://www.doudoutxt.com/files/article/51465/281rs374.html