Case JDKJDK1.8 HashMap two kinds of expansion and turn red-black tree

JDK1.8 HashMap two kinds of expansion situation.
1, when the threshold number is equal to the actual map threshold capacity, it will be twice the expansion.
2, when the chain length of the array in a map of the tub is greater than a threshold value tree 8 TREEIFY_THRESHOLD =,
and the number of map elements is less than the minimum capacity of the tree MIN_TREEIFY_CAPACITY = 64 times, capacity two-fold expansion.

Otherwise the tree and the number of the threshold value map element 8 is greater than 64, a transfer list red-black tree.

put method

treeifyBean tree method:

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/cyrbjh/p/11816697.html