JAVA common type

1, set to heavy calling hashmap implementation.

2, hashmap bottom maintains a node [] table, table [hash value] stored key corresponding node, node achieved map.entry. node {hash, key, value, next}

 .put map (), first call hashcode () generates a hash value, if the Table [hash] is null, the description does not exist in the map key, then the insertion node. If Table [hash] is not empty, the matching hash value, and equals (key), if the same value is updated, continue traverse different node Next, the iteration is complete if no matching node to insert a new node. Table [hash] is a list node (entry) is tantamount to having a hash value
hash value is the index table of the array, it is possible to achieve O (1) and to re-access.

3, hashmap hashcode and equals method to be invoked, so the custom class as a key, needs to be rewritten Object class hashcode () and equals () methods.

Guess you like

Origin www.cnblogs.com/csyusu/p/10932029.html