方式1:
Iterator<String> iterator = map.keySet().iterator();
while (iterator.hasNext()) {
String key = (String) iterator.next();
String value = map.get(key);
}
方式2:
for (String key : map.keySet()) {
String value = map.get(key);
}
方式3:
Iterator<Entry<String, String>> iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, String> entry = (Map.Entry<String, String>) iterator.next();
String key = entry.getKey();
String value = entry.getValue();
}
方式4:
for (Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
}
来源:oschina
链接:https://my.oschina.net/u/1024408/blog/165453