Boolean evict) {
Node
If ((TAB=table)==null | | (n=TAB. Length)==0)
N=(TAB=the resize ().) length;
If ((p=TAB [I=(n - 1) & amp; hash])==null)
TAB [I]=newNode (hash, key, value, null);
A HashMap putVal method, why a new local variable Node< alone; K, V> [] TAB, the TAB=table. Direct operation table
CodePudding user response:
Is the capacity you need a new oneCodePudding user response:
Table is a member variable, TAB=table, the resize () method returns the new NodeReference the address is the same.
Node
If ((TAB=table)==null | | (n=TAB. Length)==0)
N=(TAB=the resize ().) length;
If ((p=TAB [I=(n - 1) & amp; hash])==null)
TAB [I]=newNode (hash, key, value, null);
The else {
Node
If (p.h ash==hash & amp; &
(k=p.k ey)==key | | (key!=null & amp; & Key. Equals (k))))
E=p;
Is a bit like e and p, e and p are just different objects, is a shallow copy of the p, e reference address is the same. E, p will change accordingly. Why again a new e. direct operation p. Around people dizzy.