oddLotList = oddLotList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(OddLot::getAccountCode))), ArrayList::new)); 红色字体:oddLotList --> 传入list;OddLot::getAccountCode --> 根据list中属性的那个字段; ArrayList::new --> 去重后过滤到的Collections形式
Java通过Stream的方式根据Object的某属性对List<Object>去重
最新推荐文章于 2023-07-14 14:30:00 发布