HashMap<String, Object> map = new HashMap<String, Object>();
map.put("1", "浙江");
map.put("2", "安徽");
map.put("3", "河南");
map.put("4", "江西");
map.put("5", "广东");
for (Map.Entry<String, Object> entry : map.entrySet()) {
System.out.println("key = " + entry.getKey() + ", value = " + entry.getValue());
}
for (String key : map.keySet()) {
System.out.println("key = " + key);
}
for (Object value : map.values()) {
System.out.println("key = " + value);
}
Iterator<Map.Entry<String, Object>> it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Object> entry = it.next();
System.out.println("key = " + entry.getKey() + ", value = " + entry.getValue());
}
map.forEach((key, value) -> {
System.out.println(key + ":" + value);
});