一:遍历map
public static void main(String[] args) {
Map<String, String>map = new HashMap<String, String>();
map.put("name", "sunguodong");
map.put("city", "sh");
map.forEach((k,v)->{
System.out.println(k);
System.out.println(v);
});
}
二:遍历list
public static void main(String[] args) {
List<String> list = new ArrayList<>();
list.add("xiaohong");
list.add("xiaobai");
list.forEach(item->{
System.out.println(item);
});
}