点击:曾经写的简单样例
1.有个实体类,想获得他的id对应name的一个map
Map<Long, Integer> weightMap =
chapterRelationList.stream()
.collect(Collectors
.toMap(ChapterRelation::getChapterId,
ChapterRelation::getWeight));
2.想获得他的一个属性id的list(中间就是要的属性)
List<Long> chapterRelationIds = chapterRelationList
.stream()
.map(ChapterRelation::getId)
.collect(Collectors.toList());
3.全改变一个对象集合的某个值
tutorials.stream().forEach(e->e.setDeleteStatus(false));