1.使用filter()过滤List

//查找身高在1.8米及以上的男生 List<StudentInfo> boys = studentList.stream().filter(s->s.getGender() && s.getHeight() >= 1.8).collect(Collectors.toList()); //输出查找结果 StudentInfo.printStudents(boys);
原文:https://www.cnblogs.com/fxx5/p/14957429.html