Java | Loop a Map
I think this is the best way I found to loop through a Map in Java.
public void printMap(Map mp) { Iterator it = mp.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry)it.next(); System.out.println("Key:" + pairs.getKey() + ", Value:" + pairs.getValue()); } }
Leave a Reply