Stream流根据对象的某个字段去重

//去重
msgs = msgs.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Msg :: getMsgId))), ArrayList::new));

你可能感兴趣的:(JAVA,后端,技术,stream)