📜  java iterate hashmap - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:27.564000             🧑  作者: Mango

代码示例6
public static void printMap(Map mp) {
    Iterator it = mp.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry pair = (Map.Entry)it.next();
        System.out.println(pair.getKey() + " = " + pair.getValue());
        it.remove(); // avoids a ConcurrentModificationException
    }
}