I've got HashMap with HashSet as value How to iterate over it ti reseive result like:
key1
value1
value2
value3
...
key2
value1
value2
value3
key3
...
I have something wrong in my code:
Map<String, HashSet<String>> remarksMap = new HashMap<String, HashSet<String>>();
//...
Iterator<Map.Entry<String, HashSet<String>>> itr1 = remarksMap.entrySet().iterator();
Iterator<String> itr2 = itr1.next().getValue().iterator();
while (itr1.hasNext()) {
System.out.println(itr1.next().getKey());
while (itr2.hasNext()) {
System.out.println(itr2.next());
}
}
Currently receiving wrong result like:
key1
value1
value2
value3
key2
key3
key4
...