0

How do you iterate through a HashMap with the iterator object

11th Sep 2022, 1:17 PM
Bash Athekame
Bash Athekame - avatar
2 ответов
+ 3
Create entrySet() then create iterator for it. HashMap hm = new HashMap() ; Iterator it = hm.entrySet().iterator(); Now it.next() returns a mapEntry() which have key, value pair. MapEntry<> e = it.next() ; e.getKey() returns key m.getValue() returns value... Hope it helps...
11th Sep 2022, 1:39 PM
Jayakrishna 🇮🇳
11th Sep 2022, 1:39 PM
SoloProg
SoloProg - avatar