HashMap put()和get()方法如何工作的内部机制(仅限基本逻辑) [英] Internals of how the HashMap put() and get() methods work (basic logic only )
问题描述
当我们使用 编辑:我不想在这里找到细节,基本上试图理解更大的图像和 如果你谈论更高级的图片,它就像下面这样。在这里我把item称为 放置物品时 获取: When we put a key instance say "key" and a Value instance say "value" in a Edit: I do not want details here , basically trying to understand the bigger picture and the role of If you talk about higher picture it is just like below.Here i refer item as a While Putting items. Get:
这篇关于HashMap put()和get()方法如何工作的内部机制(仅限基本逻辑)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! put()在
HashMap
类中放置一个关键实例时,将key和一个Value实例声明为value code>方法, HashMap
类在内部是做什么的。当我们说 hashMap.get(key)
?
equals()
和 hashcode() code> put()
和 get()
操作中的code方法。键
of 地图
hashcode
篮子 code>存在
hashcode
,然后使用 equals
方法在关键字上搜索关键字i以确定元素是否被添加或替换。
ol>
哈希码
equals >迭代将返回该元素。
HashMap
class using put()
method , what does the HashMap
class do internally . How does it retrieve the value back when we say hashMap.get(key)
?equals()
and hashcode()
method in put()
and get()
operations.key
of Map
hashcode
of key basket
with that hashcode
is present then use the equals
method on the key search the keys i that basket to determine if the element is to be added or replace.
hashcode
of keyequals
on the key will return you that element from that basket.