Stream类处理集合改变集合元素的某个属性
1.
list = list.stream().map(s -> s.setAge(s.getAge() + 1)).collect(Collectors.toList());
2.
list.stream().forEach(x->{x.age+=1;});
1.
list = list.stream().map(s -> s.setAge(s.getAge() + 1)).collect(Collectors.toList());
2.
list.stream().forEach(x->{x.age+=1;});