keySet()
for (String key : map.keySet()) {
System.out.println(key);
}
values()
for (String value : map.values()) {
System.out.println(value);
}
entrySet()
for (Map.Entry<String, String> entry : map.entrySet()) {
String k = entry.getKey();
String v = entry.getValue();
System.out.println(k + " : " + v);
}
lambda
map.forEach((k, v) -> {
System.out.println(k + " : " + v);
});
Iterator
Iterator<Map.Entry<String, String>> entries = map.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry<String, String> entry = entries.next();
String key = entry.getKey();
String value = entry.getValue();
System.out.println(key + " : " + value);
}
标签:Map,遍历,String,map,System,println,集合,entry,out From: https://www.cnblogs.com/sasori-puppet/p/18103620