1、对象去重
currencyAttrConfigs.stream().collect(Collectors.collectingAndThen( Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CurrencyAttrConfig::getName))), ArrayList::new));
2、并行流
List.stream().parallel().forEach
3、求和
Integer total = list.stream.mapToInt(item -> item.getAge()).sum();
4、排序
正序:
List<LotteryConfig> filterSortLotteryConfigs = lotteryConfigs.stream() .filter(item -> item.getUserType() == userType) .sorted(Comparator.comparing(LotteryConfig::getAwardLevel)) .collect(Collectors.toList());
倒序:
List<LotteryConfig> filterSortLotteryConfigs = lotteryConfigs.stream() .filter(item -> item.getUserType() == userType) .sorted(Comparator.comparing(LotteryConfig::getAwardLevel).reversed()) .collect(Collectors.toList());