一文读懂HashMap和HashTable的区别以及常见面试题(18)


       
       threshold = newThr;
       @SuppressWarnings({\"rawtypes\"\"unchecked\")
           Node<KV>[
newTab = (Node<KV>[
)new Node[newCap
;
       table = newTab;        if (oldTab != null) {            for (int j = 0; j < oldCap; ++j) {
               Node<KV> e;                if ((e = oldTab[j
) != null) {
                   oldTab[j
= null;                    if (e.next == null)                        //当后面没有节点时 , 直接插入即可 //每个元素重新计算索引位置 , 此处的hash值并没有变 , 只是改变索引值
                       newTab[e.hash & (newCap - 1)

推荐阅读