HashMap 与 hashCode
- 集合
HashMap<K,V>
使用数组Node<K,V>[] table
存储数据,通过散列码int hash
计算数组索引int index
以存取数据; - 容量
int capacity
值为2
(0 ≤ n ≤ 30)(最小值为1
最大值为1073741824
1),数组索引int index
最大值为(capacity -1) = 1073741823
,散列码值范围为-2147483648 ≤ hashCode ≤ 2147483647
2(含0
值的总个数为4294967296
是容量int capacity
最大值的4
倍)。
容量和最大索引取值表
HashMap 散列索引
int h = key.hashCode(