Maps do not provide an iterator() method as do Lists and Sets. A Set of either keys (keySet()) or key-value Map.Entry elements (entrySet()) can be obtained from the Map, and one can iterate over that.
Example:
public static void dumpMap(Map mp) {
Iterator it = mp.entrySet(
while (it.hasNext()) {
Map.Entry pairs = (Map.Entry)it.next();
System.out.p
}
}
No comments:
Post a Comment