Reputation: 159
I would like to store multiple values for a single key and must be able to retrieve the specific value.
Is there any data structure in Java which have this kind of functionality? If so, please let me know.
Upvotes: 2
Views: 4726
Reputation: 94645
You may use Map<key,List<T>>
HashMap<String,ArrayList<String>> map;
Upvotes: 9
Reputation: 80176
There is no support in JDK. What you want is a Multimap
and guava library provides it.
Upvotes: 8