public static void main(String[] args) {
List<User> list = new ArrayList<>();
for(int i=1;i<=10;i++) {
list.add(new User(i, "user_" + i));
}
//list forEach
list.forEach(user -> {
user.setId(user.getId() + 10);
System.out.println(user);
});
}
public static void main(String[] args) {
Map<Integer, User> map = new HashMap<>(10);
for(int i=1;i<=10;i++) {
map.put(i, new User(i, "user_" + i));
}
//map forEach
map.forEach((k, v) -> {
System.out.println("key: " + k + ", value:" + v);
});
}