当前位置:网站首页>Talk about your understanding of hashcode and equals methods?
Talk about your understanding of hashcode and equals methods?
2022-07-25 13:33:00 【Ziqian 2014】
One 、 effect
hashCode() To get hash code , Also known as hash code ; It actually returns a int Integers . The function of this hash code is to determine the index position of the object in the hash table .
equals Its function is to judge whether two objects are equal , If the object overrides equals() Method , Compare the contents of two objects to see if they are equal ; If you don't rewrite it , Compare the addresses of two objects , Equivalent to “==”.
Two 、 usage
When storing elements into a hash table , Will call the object first hashCode Method , Calculate the storage location of the object in the hash table , If there is no element in this position, it is directly stored , If there is an element in this position, there is a hash conflict , At this time, the... Of the object will be called equals Method , Compare whether the two objects are the same , If equals Method returns true, Then the second object will not be stored in the hash table , If you return false, Will be deposited .
边栏推荐
- 刷题-洛谷-P1152 欢乐的跳
- Mujoco+spinningup for intensive learning training quick start
- Online Learning and Pricing with Reusable Resources: Linear Bandits with Sub-Exponential Rewards: Li
- JS Array indexOf includes sort() 冒号排序 快速排序 去重和随机样本 random
- 刷题-洛谷-P1047 校门外的树
- QGIS loading online map: Gaode, Tiandi map, etc
- Convolutional neural network model -- lenet network structure and code implementation
- 刷题-洛谷-P1059 明明的随机数
- ES6数组去重 new Set()
- 刷题-洛谷-P1075 质因数分解
猜你喜欢

ESP32-C3 基于Arduino框架下Blinker点灯控制10路开关或继电器组

刷题-洛谷-P1035 级数求和

基于百问网IMX6ULL_PRO开发板驱动AP3216实验

The whole process of 6w+ word recording experiment | explore the economical data storage strategy of alluxio
HTTP cache tongtianpian, there may be something you want

运动豪华还是安全豪华?亚洲龙与沃尔沃S60该入手哪款?

Sports luxury or safety luxury? Which type of Asian Dragon and Volvo S60 should we start with?

【AI4Code】《IntelliCode Compose: Code Generation using Transformer》 ESEC/FSE 2020

6.27 uniapp project history

6.27 uniapp项目历程
随机推荐
0713RHCSA
HTTP cache tongtianpian, there may be something you want
0720RHCSA
How to refactor embedded code?
JS Array indexOf includes sort() 冒号排序 快速排序 去重和随机样本 random
C#基础学习(二十三)_窗体与事件
Django 2 ----- 数据库与Admin
0720RHCSA
0710RHCSA
Peripheral system calls SAP's webapi interface
面试官问我:Mysql的存储引擎你了解多少?
C # basic learning (XXIII)_ Forms and events
基于百问网IMX6ULL_PRO开发板驱动AP3216实验
mujoco_ Py Chinese document
mujoco_py中文文档
The whole process of 6w+ word recording experiment | explore the economical data storage strategy of alluxio
QGIS加载在线地图:高德、天地图等
MLIR原理与应用技术杂谈
Leetcode 113. 路径总和 II
手写jdbc的使用步骤?