Want to share an understanding of HashMap:
We first need to know the composition of a HashMap object, the general understanding is: A map contains a number of key-value pairs, together is a key-value pairs of arrays;
Probably understand that, but one thing to say, in this array of key-value pairs, the memory space of each element of the array is not necessarily the same as the key value, this depends on the situation.
We understand the hashmap of the implementation of the principle of understanding why.
=======================================================
We create a hashmap usually as follows:
HASHMAP MP = new HashMap ();
When we use the map put (Key,value) method to fill in the value, HashMap will pass the key you passed in to calculate a hash value, no matter how long you pass the string, will be calculated by the value of an int class type, collectively known as the hash value, The hash value is then processed to get an array subscript. The system will enclose the key and value we passed into a entry object in this address. The problem is that, different hash to calculate the array subscript, the result may be the same, and this subscript has been used before, stored another pair of key values; HashMap will add a storage unit behind this subscript element to store the oldest key value (the new one is placed in its original position). These two pairs of key values are linked in an array element by a linked list.
=================
Say so much first,,, and later add
Java feature-hashmap