Skip to content

Commit be8db35

Browse files
authored
Update HashMap.md
1 parent ac77326 commit be8db35

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/java/HashMap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ HashMap只提供了put用于添加元素,putVal方法只是给put方法调用
235235
**对putVal方法添加元素的分析如下:**
236236

237237
- ①如果定位到的数组位置没有元素 就直接插入。
238-
- ②如果定位到的数组位置有元素就和要插入的key比较,如果key相同就直接覆盖,如果key不相同,就判断p是否是一个树节点,如果是就调用`e = ((TreeNode<K,V>)p).putTreeVal(this, tab, hash, key, value)`将元素添加进入。如果不是就遍历链表插入。
238+
- ②如果定位到的数组位置有元素就和要插入的key比较,如果key相同就直接覆盖,如果key不相同,就判断p是否是一个树节点,如果是就调用`e = ((TreeNode<K,V>)p).putTreeVal(this, tab, hash, key, value)`将元素添加进入。如果不是就遍历链表插入(插入的是链表尾部)
239239

240240

241241

0 commit comments

Comments
 (0)