java8 List 根據對象某個字段或多個字段去重

方式一:

List<Order> orderList = Lists.newArrayList();
orderList .stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()
                -> new TreeSet<>(Comparator.comparing(o
                -> o.getId()))), ArrayList::new));
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章