方法一:
//整个list去重
List newship = articleIdsList.stream().distinct().collect(Collectors.toList());
方法二:
// list中相同字段去重
ArrayList arrayList = newList.stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(
Comparator.comparing(// 对象的某一个属性
TblScmArticleAndClassifyVo::getArticleId))), ArrayList::new));
//list按时间倒叙(成功)
Collections.sort(finialList, new Comparator() {
public int compare(TblScmArticleAndClassifyVo s1, TblScmArticleAndClassifyVo s2) {
return s2.getUpShelvesTime().compareTo(s1.getUpShelvesTime());
}
});
//list按时间倒叙(不成功)
List finialListcollect = finialList.stream().sorted(Comparator.comparing(TblScmArticleAndClassifyVo::getUpShelvesTime).reversed()).collect(Collectors.toList());