map的遍历

JDK8推荐使用

map.forEach((K, V) -> {
System.out.println("Key : " + K);
System.out.println("Value : " + V);
});

 foreach推荐使用

for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println("Key : " + entry.getKey());
System.out.println("Value : " + entry.getValue());
}

不推荐使用

for (String key : map.keySet()) {
System.out.println("Key : " + key);
System.out.println("Value : " + map.get(key));
}
原文地址:https://www.cnblogs.com/leeego-123/p/12069053.html