jdk1.8新特性


遍历map
Map map = new HashMap<>();
map.put("name","张三");
map.put("age","28");
map.put("siteId","100000");

jdk1.8之前
// 增强for循环
for(mapEntry(String,Object) entry:map.entrySet()){
System.out.println(entry.getKey()+":"+ entry.getValue());
}

jdk1.8
// foreach
map.forEach((key,value) ->
System.out.println(key+":"+value);
)