当前位置:网站首页>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 .
边栏推荐
- how to prove compiler‘s correctness
- PMP對工作有益嗎?怎麼選擇靠譜平臺讓備考更省心省力!!!
- AD域组策略管理
- Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
- Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
- 怎么在手机上买股票开户 股票开户安全吗
- LeetCode_7_5
- MSE API学习
- Visual Studio 插件之CodeMaid自动整理代码
- torch.nn.functional.pad(input, pad, mode=‘constant‘, value=None)记录
猜你喜欢

vulnhub之Funfox2

模拟实现string类

Dynamic addition of El upload upload component; El upload dynamically uploads files; El upload distinguishes which component uploads the file.

The state cyberspace Office released the measures for data exit security assessment: 100000 information provided overseas needs to be declared

多个线程之间如何协同

Kirin Xin'an cloud platform is newly upgraded!

LeetCode_7_5

爬虫实战(七):爬王者英雄图片

Empowering smart power construction | Kirin Xin'an high availability cluster management system to ensure the continuity of users' key businesses

Openeuler prize catching activities, to participate in?
随机推荐
LeetCode_7_5
Welcome to the markdown editor
关于ssh登录时卡顿30s左右的问题调试处理
PMP对工作有益吗?怎么选择靠谱平台让备考更省心省力!!!
Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
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
IP tools
what‘s the meaning of inference
How to buy bank financial products? Do you need a bank card?
小试牛刀之NunJucks模板引擎
9 原子操作类之18罗汉增强
How to cooperate among multiple threads
841. 字符串哈希
【STL】vector
Compiler optimization (4): inductive variables
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
位运算介绍
R language ggplot2 visualization: use the ggqqplot function of ggpubr package to visualize the QQ graph (Quantitative quantitative plot)
一锅乱炖,npm、yarn cnpm常用命令合集
Download from MySQL official website: mysql8 for Linux X Version (Graphic explanation)