Java中给List<T> 对象集合去重

Java中给List 对象集合去重

java 复制代码
  List<Student> getStudentList = studentMapper.getStudentList();
           List<Student> distinctInsurance = distinctByField(getStudentList, Student::getCertNo);
java 复制代码
    public static <T> List<T> distinctByField(List<T> list, Function<T, Object> fieldExtractor) {
        Set<Object> seen = new HashSet<>();
        return list.stream()
                .filter(item -> seen.add(fieldExtractor.apply(item)))
                .collect(Collectors.toList());
    }
相关推荐
白毛大侠7 分钟前
理解 Go 接口:eface 与 iface 的区别及动态性解析
开发语言·网络·golang
李昊哲小课23 分钟前
Python办公自动化教程 - 第7章 综合实战案例 - 企业销售管理系统
开发语言·python·数据分析·excel·数据可视化·openpyxl
Hou'23 分钟前
从0到1的C语言传奇之路
c语言·开发语言
不知名的老吴1 小时前
返回None还是空集合?防御式编程的关键细节
开发语言·python
计算机毕设指导61 小时前
基于SpringBoot校园学生健康监测管理系统【源码文末联系】
java·spring boot·后端·spring·tomcat·maven·intellij-idea
mysuking1 小时前
springboot与springcloud对应版本
java·spring boot·spring cloud
希望永不加班1 小时前
SpringBoot 数据库连接池配置(HikariCP)最佳实践
java·数据库·spring boot·后端·spring
迈巴赫车主1 小时前
蓝桥杯3500阶乘求和java
java·开发语言·数据结构·职场和发展·蓝桥杯
小菜鸡桃蛋狗1 小时前
C++——string(上)
开发语言·c++
chushiyunen1 小时前
python pygame实现贪食蛇
开发语言·python·pygame