public static void main(String[] args) { List<DealerCodeExcelDTO> list = new ArrayList<>(); DealerCodeExcelDTO dealerCodeExcelDTO = new DealerCodeExcelDTO(); dealerCodeExcelDTO.setDealerCode("11"); list.add(dealerCodeExcelDTO); DealerCodeExcelDTO dealerCodeExcelDTO1 = new DealerCodeExcelDTO(); dealerCodeExcelDTO1.setDealerCode("13"); list.add(dealerCodeExcelDTO1); DealerCodeExcelDTO dealerCodeExcelDTO2 = new DealerCodeExcelDTO(); dealerCodeExcelDTO2.setDealerCode("14"); list.add(dealerCodeExcelDTO2); DealerCodeExcelDTO dealerCodeExcelDTO3 = new DealerCodeExcelDTO(); dealerCodeExcelDTO3.setDealerCode("11"); list.add(dealerCodeExcelDTO3); List<DealerCodeExcelDTO> filterList = list.stream().filter(a -> (a.getDealerCode().equals("11"))).collect(Collectors.toList()); filterList.removeAll(Collections.singleton(null)); List<String> collect = filterList.stream().map(t -> t.getDealerCode()).distinct().collect(Collectors.toList()); System.out.println(collect); }
list去重去空
最新推荐文章于 2024-07-11 14:18:10 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)