使用stream().filter()来过滤一个List对象,查找符合条件的对象集合。
//查找身高在1.8米及以上的男生
List<StudentInfo> boys = studentList.stream().filter(s->s.getGender() && s.getHeight() >= 1.8).collect(Collectors.toList());
使用stream().filter()来过滤一个List对象,查找符合条件的对象集合。
//查找身高在1.8米及以上的男生
List<StudentInfo> boys = studentList.stream().filter(s->s.getGender() && s.getHeight() >= 1.8).collect(Collectors.toList());