Tuesday, January 29, 2013

Internals of the OpenJDK - HashMap

Here is the implementation of HashMap from OpenJDK 6.  It is interesting how simple it truly is.  Essentially HashMap consists of an array called 'table'.  On the 'put' call, we use the hashcode of the key and then call another hash function, then convert that into an index into the array.  Place the 'value' object at the index array position.

OpenJDK HashMap Implementation