I have created a Hashmap which has multiple entries for a single Key entry. Now I want to retrieve all values individually. How can I do this?
I have checked many sites but couldn't get a clue on how to implement it, and an example code snippet can be useful for me.
HashMap<String,String>
key value
04302014 04302014
04302014 abc
04302014 10
04302014 20
04302014 20
05302014 05302014
05302014 def
05302014 10
05302014 20
05302014 20
Now using the key
I want to retrieve all values individually and store in variables.
Like for key 04302014
I need to extract once and store in variables and in second iteration for the key 05302014
.
A Hashmap only has one value for each key, so this will not be possible. You would need a Multimap for this (as in Guava for example), or a Map to a List of values.