Java‎ > ‎

Map

Iterate a Map

import java.util.*;
import java.util.Map.Entry;

Iterator entries = myMap.entrySet().iterator();
while (entries.hasNext()) {
  Entry thisEntry = (Entry) entries.next();
  Object key = thisEntry.getKey();
  Object value = thisEntry.getValue();
  System.out.println("* " + key.toString() + ": " + value.toString());
}



Comments