Common data Structures in Java
Common data structures are hash tables, linear lists, linked lists, and java.util packages with three important interfaces: List,set,map commonly used to implement basic data structures
How the HashMap works
HashMap based on the hashing principle, we store and retrieve object elements through the put (Key,value) and get (key) methods, and when we pass the key value to the put () method, the Hashcode method of the object element is automatically called to calculate hashcode, Then the location of the object element is determined according to Hashcode.
When we get the object, we find the specific key-value pair entry according to the Equals method of the Key object, and then return the value object;
HashMap uses the list to solve the problem of hash conflict, when a hash conflict occurs, the object is stored on the next node of the list
HashMap is thread insecure, Courrenthashmap is thread-safe (using a segmented lock to lock part of a map)
What are the data structures in Java? How does HashMap work?