当前位置:网站首页>【面试题】instancof和getClass()的区别
【面试题】instancof和getClass()的区别
2022-06-24 19:48:00 【不想睡觉的橘子君】
最近在了解《Effective Java》中提到的eques方法的限制时,有讲到igetClass()可以替代nstanceof来判断是否是同一个子类。于是了解了一下两者的区别。
简单的说,它们的区别是,同样是判断子类和父类是否相等,子类 instanceof 父类 为true
子类.getClass() == 父类.getClass() 为false.
因为这一点简单的差别,在实现子类的equals()方法时,要多加注意
边栏推荐
- Hello C (VI) -- pointer and string
- Window system installation Nacos
- 机器学习自学成才的十条戒律
- Tutorial details | how to edit and set the navigation function in the coolman system?
- Global and Chinese tetrahydrofurfuryl butyrate industry operation pattern and future prospect report 2022 ~ 2028
- HMS core discovery Episode 13 live broadcast Preview - building the real world in mobile games
- Tomorrow is the PMP Exam (June 25). Have you understood all this?
- Today's sleep quality record 79 points
- 怎么把wps表格里某一列有重复项的整行删掉
- Tongji and Ali won the CVPR best student thesis, lifeifei won the Huang xutao award, and nearly 6000 people attended the offline conference
猜你喜欢

有趣的checkbox计数器

How does VR panorama make money? Based on the objective analysis of the market from two aspects

技术分享| WVP+ZLMediaKit实现摄像头GB28181推流播放

Eye gaze estimation using webcam

Hello C (I) -- basics of C language

Nacos究竟是什么

年薪百万,7年测试经验:守在一个还算不错的赛道,慢慢积累,等风来

7-6 laying oil well pipeline

Today's sleep quality record 79 points

Go language pointer, value reference and pointer reference
随机推荐
Understanding openstack network
STM32CubeIDE SWV功能使用方法
7-7 solving mode problems
Why is it that the "Zhongtai" that was originally eaten by civil engineering is no longer fragrant?
信号完整性(SI)电源完整性(PI)学习笔记(一)信号完整性分析概论
【图数据库性能和场景测试利器LDBC SNB】系列一:数据生成器简介 & 应用于GES服务
时间统一系统
水库大坝安全监测
Nominal resistance table of patch resistors with 5% and 1% accuracy
Ethernet ARP Protocol
Morris traverse
Global and Chinese 3-Chlorobenzaldehyde industry operation mode and future development trend report 2022 ~ 2028
机器学习自学成才的十条戒律
Tongji and Ali won the CVPR best student thesis, lifeifei won the Huang xutao award, and nearly 6000 people attended the offline conference
Hibernate learning 3 - custom SQL
Adding, deleting, querying and modifying MySQL tables
5G dtu无线通信模块的电力应用
Assessment of public finance of Jilin University in March of the 22nd spring -00091
为什么生命科学企业都在陆续上云?
Laravel framework knowledge