java - How to iterate on hashmap that have k,v of string and list? -
i have hashmap this:
hashmap<string, list<string>> total=new hashmap<>();
and have hashmap k,v , want iterate , print each key key values have including duplicates, , each duplicate print key again, this:
123 john 123 tom 123 jack 234 terry 234 jeniffer 345 jacob 555 sara
for (map.entry<string, list<string>> entry : total.entryset()) { (string s : entry.getvalue()) { system.out.println(entry.getkey() + " " + s); } }
Comments
Post a Comment