当前位置:网站首页>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 .
边栏推荐
- 时间工具类
- RESTAPI 版本控制策略【eolink 翻译】
- R language uses ggplot2 function to visualize the histogram distribution of counting target variables that need to build Poisson regression model, and analyzes the feasibility of building Poisson regr
- Detailed explanation of Flink parallelism and slot
- 831. KMP string
- LC: string conversion integer (ATOI) + appearance sequence + longest common prefix
- J ü rgen schmidhub reviews the 25th anniversary of LSTM papers: long short term memory All computable metaverses. Hierarchical reinforcement learning (RL). Meta-RL. Abstractions in generative adversar
- What does "true" mean
- tp6 实现佣金排行榜
- torch. nn. functional. Pad (input, pad, mode= 'constant', value=none) record
猜你喜欢
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
Simulate the implementation of string class
Compiler optimization (4): inductive variables
Interpretation of transpose convolution theory (input-output size analysis)
ASP.NET幼儿园连锁管理系统源码
位运算介绍
Detailed explanation of Flink parallelism and slot
小试牛刀之NunJucks模板引擎
The project manager's "eight interview questions" is equal to a meeting
8 CAS
随机推荐
干货分享|DevExpress v22.1原版帮助文档下载集合
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
R语言ggplot2可视化:使用ggpubr包的ggdensity函数可视化分组密度图、使用stat_overlay_normal_density函数为每个分组的密度图叠加正太分布曲线
My creation anniversary
JVM 类加载机制
强化学习-学习笔记8 | Q-learning
Ucloud is a basic cloud computing service provider
Kirin Xin'an cloud platform is newly upgraded!
注解。。。
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
Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
How to cooperate among multiple threads
AD域组策略管理
Matplotlib drawing 3D graphics
模拟实现string类
Welcome to the markdown editor
831. KMP字符串
sql 常用优化
【剑指offer】剑指 Offer II 012. 左右两边子数组的和相等
MIT科技评论文章:围绕Gato等模型的AGI炒作可能使人们忽视真正重要的问题