当前位置:网站首页>【面试题】instancof和getClass()的区别
【面试题】instancof和getClass()的区别
2022-06-24 19:48:00 【不想睡觉的橘子君】
最近在了解《Effective Java》中提到的eques方法的限制时,有讲到igetClass()可以替代nstanceof来判断是否是同一个子类。于是了解了一下两者的区别。
简单的说,它们的区别是,同样是判断子类和父类是否相等,子类 instanceof 父类 为true
子类.getClass() == 父类.getClass() 为false.
因为这一点简单的差别,在实现子类的equals()方法时,要多加注意
边栏推荐
猜你喜欢

浅析大型IM即时通讯系统开发难度

∞ symbol line animation canvasjs special effect

UE4 WebBrowser图表不能显示问题

svg+js键盘控制路径

为什么生命科学企业都在陆续上云?

Tiktok actual combat ~ sorting out the short video release process

ArcGIS loads free online historical images as the base map (no plug-ins are required)

Outer screen and widescreen wasted? Harmonyos folding screen design specification teaches you to use it

Monotone stack and its application

VR全景制作的优势是什么?为什么能得到青睐?
随机推荐
在滴滴和字节跳动干了 5年软件测试,太真实…
7-8 circular scheduling problem
Hello C (IV) -- pointer and function
Scala IO reads data from URLs and other data sources
U.S. House of Representatives: digital dollar will support the U.S. dollar as the global reserve currency
创意SVG环形时钟js特效
部门新来的00后真是卷王,工作没两年,跳槽到我们公司起薪18K都快接近我了
Why do more and more physical stores use VR panorama? What are the advantages?
Hello C (VI) -- pointer and string
Andersen global strengthens the Middle East platform with Palestinian member companies
Understanding openstack network
Ten commandments of self-learning in machine learning
Number of bytes corresponding to common data types
Tongji and Ali won the CVPR best student thesis, lifeifei won the Huang xutao award, and nearly 6000 people attended the offline conference
Assessment of public finance of Jilin University in March of the 22nd spring -00091
Enterprise data leakage prevention solution sharing
JPA学习2 - 核心注解、注解进行增删改查、List查询结果返回类型、一对多、多对一、多对多
同济、阿里获CVPR最佳学生论文,李飞飞获黄煦涛奖,近6000人线下参会
Nacos究竟是什么
Investment analysis and prospect forecast report of global and Chinese propargyl chloride industry from 2022 to 2028