- HashMap
data structure
JDK1.7
HashMap consists of an array + linked list. The array is the main body of HashMap, and the linked list exists mainly to solve hash conflicts.
JDK1.8
HashMap consists of an array + linked list / red-black tree. When the length of the linked list is greater than the threshold (the default is 8), the linked list is converted into a red-black tree to reduce the search time.
After being converted into a red-black tree, the structure of the linked list will still exist, maintained by the next attribute, and the red-black tree node will maintain the structure of the linked list when it is operating .
Underlying principles
How to achieve access?
- put
- get
- null key
Source code analysis
- ConcurrentHashMap
data structure
Underlying principles
Source code analysis