Saturday, March 21, 2015

Digging Deeper Into Java's HashMap

This post is about Java's HashMap. Even though it is filled under Beginning Java tag, it won't be an introductory post on how to begin using HashMap: its API or the common tasks you can accomplish with it. It would be a peep into how HashMap works, how it is implemented, with the hope that knowing this would provide more insight into what goes on whenever HashMap is being used.

I would wager that HashMap is probably one of the most readily used data structures when programming in Java. The functionality it provides: which is the ability to store stuff in pairs, is a particularly universal data structure need, not unique to Java. This facility goes by other names elsewhere: associative array, symbol table, dictionary or map: which HashMap is: a map implementation that is based on the concept of hashing; and by hashing, what do we mean?

Hashing is basically a transformation process; that takes a value and transform it into another form which is more desirable (due to shorter length, easy to remember etc) but still can be used to represents the original value.