Skip to content

Commit 2a14332

Browse files
authored
HashSet 底层就是基于 HashMap 实现的
如果你看过 HashSet 源码的话就应该知道:HashSet 底层就是基于 HashMap 实现的。(HashSet 的源码非常非常少,因为除了 clone() 方法、writeObject()方法、readObject()方法是 HashSet 自己不得不实现之外,其他方法都是直接调用 HashMap 中的方法。)
1 parent 60d92bd commit 2a14332

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Java相关/这几道Java集合框架面试题几乎必问.md

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ JDK1.8 之前 HashMap 由 **数组+链表** 组成的(**“链表散列”**
9898

9999
## HashSet 和 HashMap 区别
100100

101+
如果你看过 HashSet 源码的话就应该知道:HashSet 底层就是基于 HashMap 实现的。(HashSet 的源码非常非常少,因为除了 clone() 方法、writeObject()方法、readObject()方法是 HashSet 自己不得不实现之外,其他方法都是直接调用 HashMap 中的方法。)
102+
101103
![HashSet 和 HashMap 区别](https://user-gold-cdn.xitu.io/2018/3/2/161e717d734f3b23?w=896&h=363&f=jpeg&s=205536)
102104

103105
## ConcurrentHashMap 和 Hashtable 的区别

0 commit comments

Comments
 (0)