list筛选符合条件的数据作为新的list返回Lambda

2026-02-14 06:52:13

1、创建一个Student作为测试的集合对象

list筛选符合条件的数据作为新的list返回Lambda

2、创建Test类进行测试

筛选符合条件的数据作为新的List返回

List<Student> filterList = studentList


   .stream().filter((Student student) ->
       "王麻子".equals(student.getName()))
   .collect(Collectors.toList());

list筛选符合条件的数据作为新的list返回Lambda

3、输出结果

list筛选符合条件的数据作为新的list返回Lambda

4、so easy😊

猜你喜欢