Java 基础 - instanceof关键字
2024-09-06 10:18:45
instanceof 父类子类
结论:
- 子类 instanceof 父类 == true
- 父类 instanceof 子类 == false
public class Test { public static void main(String[] args) {
//instanceof 父类子类
Father father1 = new Father();
System.out.println(father1 instanceof Father ); //ture
System.out.println(father1 instanceof Son ); //false Father father2 = new Son();
System.out.println(father2 instanceof Father ); //ture
System.out.println(father2 instanceof Son ); //ture Son son = new Son();
System.out.println(son instanceof Father ); //ture
System.out.println(son instanceof Son ); //ture
}
}
最新文章
- jmeter 性能测试工具的使用(Web性能测试)
- HTML5学习总结-06 WebWorker
- openssl命令用法
- EventBus的使用,初学EventBus传值
- 在Ubuntu Linux下安装Code::Blocks和Eclipse CDT
- OCR识别流程
- 【python】二进制、八进制、十六进制表示方法(3.0以上)
- Warm up
- hdoj 1013
- 命令模式(CommandPattern)
- 银盒子智慧餐厅硬件尺寸规格&;推荐机型
- bootstrap3兼容IE8
- Python中xlutils解析
- 1873: This offer(zzuli)
- 【JMeter】接口自动化环境搭建
- jquery radio使用
- IOS初级:app的图标
- maven中的各种问题
- 建造者模式及C++实现
- 洛谷 P4066 [SHOI2003]吃豆豆 解题报告
热门文章
- form编码方式application/x-www-form-urlencoded和multipart/form-data的区别?
- 随时更新web html 项目页面,查看手机等其他移动设备的几种方法?
- 22-7map
- Pregel Aggregator
- 前端mockjs模拟图片验证码
- Java处理图片工具类
- 29. StringBuilder
- springmvc之json交互406异常(Not Acceptable)和415异常(Unsupported Media Type)
- tesserocr与pytesseract模块的使用
- 移动端图片轮播效果:depth模式总结