Alex Rivera | Logout

Map implementation with duplicate keys

Asked 2009-06-30T10:35:12.353
141

I want to have a map with duplicate keys.

I know there are many map implementations (Eclipse shows me about 50), so I bet there must be one that allows this. I know it's easy to write your own map that does this, but I would rather use some existing solution.

Maybe something in commons-collections or google-collections?

Edit
Report

1 Answer

19

You could simply pass an array of values for the value in a regular HashMap, thus simulating duplicate keys, and it would be up to you to decide what data to use.

You may also just use a MultiMap, although I do not like the idea of duplicate keys myself.

answered 2009-06-30T10:38:17.403

Your Answer