HashMap converts a collision list into a self-balancing Red-Black Tree (TreeNode<K,V>) under two strict conditions:The number of nodes in a single bucket reaches 8 (TREEIFY_THRESHOLD = 8).AND the total capacity of the array is at least 64 (MIN_TREEIFY_CAPACITY = 64).Why 8? Under ideal Poisson distribution with random hash distributions, the mathematical probability of a single bucket receiving 8 collisions naturally is less than 1 in 10,000,000 (0.00000006). Reaching 8 elements signals either a defective hashCode() implementation or a malicious HashDoS attack.If the list length reaches 8 but total table capacity is under 64, HashMap defers treeification and resizes the array instead to spread elements out
Explain when the bucket become tree in hashmap - https://tinyurl.com/34m4fw6b