Stream类处理集合改变集合元素的某个属性

1. 
list = list.stream().map(s -> s.setAge(s.getAge() + 1)).collect(Collectors.toList());
2. 
list.stream().forEach(x->{x.age+=1;});

posted on 2022-10-24 00:20  何苦->  阅读(686)  评论(0)    收藏  举报

导航