当前位置:网站首页>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 .
边栏推荐
- ASP. Net gymnasium integrated member management system source code, free sharing
- 9 atomic operation class 18 Rohan enhancement
- Install mysql8 for Linux X ultra detailed graphic tutorial
- How to buy stocks on your mobile phone and open an account? Is it safe to open an account
- Simulate the implementation of string class
- 九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
- ASP. Net kindergarten chain management system source code
- 841. String hash
- UCloud是基础云计算服务提供商
- Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
猜你喜欢
剑指 Offer II 013. 二维子矩阵的和
8 CAS
项目经理『面试八问』,看了等于会了
el-upload上传组件的动态添加;el-upload动态上传文件;el-upload区分文件是哪个组件上传的。
openEuler 资源利用率提升之道 01:概论
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
Kirin Xin'an won the bid for the new generation dispatching project of State Grid!
YoloV6:YoloV6+Win10---训练自己得数据集
LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字
The state cyberspace Office released the measures for data exit security assessment: 100000 information provided overseas needs to be declared
随机推荐
Kubernetes——kubectl命令行工具用法详解
My creation anniversary
MIT科技评论文章:围绕Gato等模型的AGI炒作可能使人们忽视真正重要的问题
Leetcode force buckle (Sword finger offer 36-39) 36 Binary search tree and bidirectional linked list 37 Serialize binary tree 38 Arrangement of strings 39 Numbers that appear more than half of the tim
Kirin Xin'an cloud platform is newly upgraded!
2022如何评估与选择低代码开发平台?
我的创作纪念日
R language dplyr package select function, group_ The by function, filter function and do function obtain the third largest value of a specific numerical data column in a specified level in a specified
Throughput
R语言ggplot2可视化:使用ggpubr包的ggviolin函数可视化小提琴图、设置palette参数自定义不同水平小提琴图的填充色、add参数在小提琴图添加箱图
Kunpeng developer summit 2022 | Kirin Xin'an and Kunpeng jointly build a new ecosystem of computing industry
模拟实现string类
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
让这个 CRMEB 单商户微信商城系统火起来,太好用了!
Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )
Redis master-slave and sentinel master-slave switchover are built step by step
Kirin Xin'an joins Ningxia commercial cipher Association
R language ggplot2 visualization: use the ggqqplot function of ggpubr package to visualize the QQ graph (Quantitative quantitative plot)
Tp6 realize Commission ranking
LC: string conversion integer (ATOI) + appearance sequence + longest common prefix