JAVA map 遍历
作者:互联网
// 1.keySet 遍历
Map<String, String> map = new HashMap<String, String>();
map.put("1", "11");
map.put("2", "22");
map.put("3", "33");
map.put("4", "44");
Set<String> entrySet = map.keySet();
for (String key : entrySet) {
System.out.println(map.get(key));
}
// 2.entrySet
Set<Map.Entry<String, String>> entrys = map.entrySet();
for (Map.Entry<String, String> set : entrys) {
System.out.println(set.getKey() + "-----" + set.getValue());
}
//3.前两种方法也可以直接用迭代 器
标签:map,set,JAVA,entrys,entrySet,System,遍历,put 来源: https://blog.51cto.com/u_12198094/2695546