/** * 按照指定字段给list去重 * @param list * @return */ public static List<DataModel> niqueList(List<DataModel> list){ //去重,根据code字段 List<DataModel> uniqueList = list.stream().collect( collectingAndThen( toCollection(() -> new TreeSet<>(comparing(n->n.getCode()))), ArrayList::new) ); return uniqueList; }

 list java8 按照指定元素去重 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2021-04-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案