当前位置:网站首页>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 .
边栏推荐
- equals 方法
- 剑指 Offer II 013. 二维子矩阵的和
- What does "true" mean
- 怎么在手机上买股票开户 股票开户安全吗
- Tp6 realize Commission ranking
- # 欢迎使用Markdown编辑器
- 开源重器!九章云极DataCanvas公司YLearn因果学习开源项目即将发布!
- torch. nn. functional. Pad (input, pad, mode= 'constant', value=none) record
- 国家网信办公布《数据出境安全评估办法》:累计向境外提供10万人信息需申报
- R language ggplot2 visualization: use the ggviolin function of ggpubr package to visualize the violin diagram, set the palette parameter to customize the filling color of violin diagrams at different
猜你喜欢

8 CAS

Sword finger offer II 013 Sum of two-dimensional submatrix

PMP對工作有益嗎?怎麼選擇靠譜平臺讓備考更省心省力!!!

Le PGR est - il utile au travail? Comment choisir une plate - forme fiable pour économiser le cœur et la main - d'œuvre lors de la préparation de l'examen!!!

【STL】vector

mock. JS returns an array from the optional data in the object array

ASP.NET幼儿园连锁管理系统源码

使用高斯Redis实现二级索引

Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!

RESTAPI 版本控制策略【eolink 翻译】
随机推荐
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
[RT thread env tool installation]
Version selection of boot and cloud
A pot of stew, a collection of common commands of NPM and yarn cnpm
Le PGR est - il utile au travail? Comment choisir une plate - forme fiable pour économiser le cœur et la main - d'œuvre lors de la préparation de l'examen!!!
微信公众号OAuth2.0授权登录并显示用户信息
Kirin Xin'an joins Ningxia commercial cipher Association
My creation anniversary
Empowering smart power construction | Kirin Xin'an high availability cluster management system to ensure the continuity of users' key businesses
Kirin Xin'an won the bid for the new generation dispatching project of State Grid!
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
Kirin Xin'an cloud platform is newly upgraded!
论文解读(ValidUtil)《Rethinking the Setting of Semi-supervised Learning on Graphs》
九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
PMP對工作有益嗎?怎麼選擇靠譜平臺讓備考更省心省力!!!
Dynamic addition of El upload upload component; El upload dynamically uploads files; El upload distinguishes which component uploads the file.
毕业季|遗憾而又幸运的毕业季
9 atomic operation class 18 Rohan enhancement
R语言fpc包的dbscan函数对数据进行密度聚类分析、查看所有样本的聚类标签、table函数计算聚类簇标签与实际标签构成的二维列联表
Redis master-slave and sentinel master-slave switchover are built step by step