1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-06-20 22:17:09 +08:00

Merge pull request #412 from LSloveYJ/patch-1

fix:fix typo
This commit is contained in:
SnailClimb 2019-08-03 20:27:30 +08:00 committed by GitHub
commit 8eba8a7e6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -109,7 +109,7 @@ public interface RandomAccess {
4. **初始容量大小和每次扩充容量大小的不同 ** ①创建时如果不指定容量初始值Hashtable 默认的初始大小为11之后每次扩充容量变为原来的2n+1。HashMap 默认的初始化大小为16。之后每次扩充容量变为原来的2倍。②创建时如果给定了容量初始值那么 Hashtable 会直接使用你给定的大小,而 HashMap 会将其扩充为2的幂次方大小HashMap 中的`tableSizeFor()`方法保证,下面给出了源代码)。也就是说 HashMap 总是使用2的幂作为哈希表的大小,后面会介绍到为什么是2的幂次方。
5. **底层数据结构:** JDK1.8 以后的 HashMap 在解决哈希冲突时有了较大的变化当链表长度大于阈值默认为8将链表转化为红黑树以减少搜索时间。Hashtable 没有这样的机制。
**HasMap 中带有初始容量的构造函数:**
**HashMap 中带有初始容量的构造函数:**
```java
public HashMap(int initialCapacity, float loadFactor) {