map的循环


Map<String, String> map = new HashMap<>();
map.put("A", "65");
map.put("B", "66");
for (String key : map.keySet()) {
String value = map.get(key);
System.out.println(key + "=" + value);
}

方法2:
System.out.println("map.forEach");
map.forEach((key,value)-> System.out.println(key+"="+value));

还有其它的,不做记录
posted @ 2024-09-12 11:00  fxg  阅读(20)  评论(0)    收藏  举报