当前位置:网站首页>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 .
边栏推荐
- 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
- IP 工具类
- Some arrangements about oneself
- YoloV6:YoloV6+Win10---训练自己得数据集
- ASP. Net gymnasium integrated member management system source code, free sharing
- openEuler 有奖捉虫活动,来参与一下?
- equals 方法
- Nunjuks template engine
- JVM GC垃圾回收简述
- Ways to improve the utilization of openeuler resources 01: Introduction
猜你喜欢

Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記

LeetCode_7_5

8 CAS

openEuler 资源利用率提升之道 01:概论

关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】

# 欢迎使用Markdown编辑器

开源OA开发平台:合同管理使用手册

PMP每日一练 | 考试不迷路-7.7

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

Flink并行度和Slot详解
随机推荐
CSDN语法说明
YoloV6:YoloV6+Win10---训练自己得数据集
MIT科技评论文章:围绕Gato等模型的AGI炒作可能使人们忽视真正重要的问题
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
openEuler 资源利用率提升之道 01:概论
torch.nn.functional.pad(input, pad, mode=‘constant‘, value=None)记录
Sword finger offer II 013 Sum of two-dimensional submatrix
mock. JS returns an array from the optional data in the object array
R语言ggplot2可视化:使用ggpubr包的ggviolin函数可视化小提琴图、设置palette参数自定义不同水平小提琴图的填充色、add参数在小提琴图添加箱图
Some arrangements about oneself
[sword finger offer] sword finger offer II 012 The sum of left and right subarrays is equal
Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
关于自身的一些安排
IP tools
位运算介绍
Introduction to bit operation
最多可以参加的会议数目[贪心 + 优先队列]
Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
Ways to improve the utilization of openeuler resources 01: Introduction
torch. nn. functional. Pad (input, pad, mode= 'constant', value=none) record