//根据排课id分组
Map<Integer, List<Schedule4Homework>> idSchedule4HomeworksMap = schedule4Homeworks.stream().collect(Collectors.groupingBy(Schedule4Homework::getScheduleId));
//根据时间排序(reversed方法表示倒序)
memberCards.sort(Comparator.comparing(MemberCard::getProfileCreated).reversed());
//分组并获取前几个
List<StoreSituation> collect = storeSituationsReturn.stream().sorted(Comparator.comparing(StoreSituation::getGmtCreate).reversed()).limit(storeSituationQuery.getRows()).collect(Collectors.toList());
//获取对象集合中某个字段的集合
List<Integer> ids = list.stream().map(p -> p.getId()).collect(Collectors.toList());
Java8 Stream分组
点赞
收藏