4 Answers
4

Chaining is used to resolve hash collisions, i.e. situations when different keys have the same hash. So, it's not about storing multiple values with the same key, it's about multiple values whose keys have the same hashes.

Data structure that can store multiple values for the same key is called a multimap. Unfortunately, there is no built-in implementation of multimap in JRE.

If you need a multimap, you can maintain a Map of Lists (as suggested by matsev), or use an existing multimap implementation from a third-party library, such as Google Guava.

Actually, it does do hash chaining. But chaining is not about storing multiple copies of the same key in a map. It is about dealing with the case where different keys map to the same slot in the hash table. That's what a collision is.
–
Stephen CDec 26 '11 at 10:52