Resize () method of HashMap Source Code in jdk1.8

clipboard.png

the red box in the picture shows that the code does not understand;
if the capacity of the original hashMap is 16 and the subscript is 15 (jacks 15), three data with a hash value of 15, 31, 47 and 47 are stored. After the expansion, the hashMap capacity is 32, and according to the code hiHead, it is 31mai 47, which is stored in the location of subscript 31 (jacks 16). But shouldn"t the position calculated by 4731 be 15?

Mar.10,2021

471160. it is not stored in hiHead, but in loHead, 473115. the storage location has not changed. The problem is caused by a miscalculation, and it is now clear

Menu