当前位置:网站首页>Equals method
Equals method
2022-07-07 20:00:00 【Whiteye too white】
“==” And equals The difference between
“==” For basic types , Compare values ; For reference types, the address is compared .
Object Class equals The default implementation of is equivalent to “==”, That is, compare the addresses of reference types .
Java There are many classes in the library ( Such as String、Date、Long、HashMap and File Class etc. ) It's all rewritten Object Class equals Method , Lead to its and “==” Unequivalence .
String Overridden in class equals First “==” Compare the reference addresses of two reference types , Same returns true, Compare the strings with different reference addresses .
rewrite equals Method must override hashCode Method
hashCode One of the things that methods actually have to do is , For the sake of equals Method returns the same hash value for the same object .
Object Class equals Method to distinguish two objects by comparing the address value , That is to use “==”. And if we rewrite it according to business needs equals Method implementation , Then it should also be rewritten at the same time hashCode Method implementation . otherwise hashCode Method still returns the basis Object Class based on address value integer Hash value .
边栏推荐
- LeetCode_7_5
- The DBSCAN function of FPC package of R language performs density clustering analysis on data, checks the clustering labels of all samples, and the table function calculates the two-dimensional contin
- 网信办公布《数据出境安全评估办法》,9 月 1 日起施行
- Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
- Specify the version of OpenCV non-standard installation
- 微信公众号OAuth2.0授权登录并显示用户信息
- Training IX basic configuration of network services
- Kubernetes——kubectl命令行工具用法详解
- 编译器优化那些事儿(4):归纳变量
- 多个线程之间如何协同
猜你喜欢
Kunpeng developer summit 2022 | Kirin Xin'an and Kunpeng jointly build a new ecosystem of computing industry
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
【STL】vector
多个线程之间如何协同
LeetCode_7_5
Matplotlib drawing 3D graphics
爬虫实战(七):爬王者英雄图片
The strength index of specialized and new software development enterprises was released, and Kirin Xin'an was honored on the list
The project manager's "eight interview questions" is equal to a meeting
Jürgen Schmidhuber回顾LSTM论文等发表25周年:Long Short-Term Memory. All computable metaverses. Hierarchical reinforcement learning (RL). Meta-RL. Abstractions in generative adversarial RL. Soccer learn
随机推荐
Browse the purpose of point setting
开源OA开发平台:合同管理使用手册
Cloud 组件发展升级
Some arrangements about oneself
网信办公布《数据出境安全评估办法》,9 月 1 日起施行
pom.xml 配置文件标签:dependencies 和 dependencyManagement 区别
openEuler 资源利用率提升之道 01:概论
Redis master-slave and sentinel master-slave switchover are built step by step
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
Make this crmeb single merchant wechat mall system popular, so easy to use!
线性基
equals 方法
what‘s the meaning of inference
R语言ggplot2可视化:使用ggpubr包的ggecdf函数可视化分组经验累积密度分布函数曲线、linetype参数指定不同分组曲线的线型
Implement secondary index with Gaussian redis
干货分享|DevExpress v22.1原版帮助文档下载集合
Flink并行度和Slot详解
sql 常用优化
【RT-Thread env 工具安装】
RESTAPI 版本控制策略【eolink 翻译】