Java 对 List 进行筛选(Stream)

2023-03-10T12:04:36

转自:Java8对List进行筛选(Stream)

//对相同内容的list进行去重
List<AppleNode> disList = appleList.stream().distinct().collect(Collectors.toList());


//取出name和code和apleNewList中的数据一致的内容
List<Apple> filterAppleList = appleNewList.stream().filter(apple-> name.equals(apple.getName()).
                                                    filter(apple -> code.equals(apple.getCode())).collect(Collectors.toList());

//根据list中的内容取出最大值对应的实体
Apple filterHs = filterHistoryList.stream().max(Comparator.comparing(Apple:getNumbet).get();
当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »