What are the differences between hashMap implementation in jdk7 and jdk8
Editor to share with you what are the differences between jdk7 and jdk8 hashMap implementation, I believe that most people do not understand, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
Jdk7: adopt the method of bit bucket (array) + linked list, which is what we often call hash linked list. The implementation class of the node is the Entry class
Jdk8: bit bucket + linked list / red-black tree is adopted. When the length of the linked list of a bit bucket is more than 8, the linked list will be converted to a red-black tree. The implementation class of the node is the Node class
The calculation of hash value is different.
Add:
Why do you use red and black trees? When using linked list, if thousands of nodes have hash conflicts, the time complexity of search will be reduced to O (n), and the time complexity of search will be reduced to O (logn) by using red-black tree.
These are all the contents of the article "what are the differences between hashMap implementations in jdk7 and jdk8?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!