anyMatch(Predicate p) 传入一个断言型函数,对流中所有的元素进行判断,只要有一个满足条件就返回true,都不满足返回false。

publicclassStudent{privateint id;private String name;privateint age;} 	List<Student> students=newArrayList<>(); 	Student student1=newStudent(); 	student1.setId(1); 	student1.setName("小余"); 	student1.setAge(18); 	students.add(student1); 	 	Student student2=newStudent(); 	student2.setId(2); 	student2.setName("小李"); 	student2.setAge(20); 	students.add(student2); 	 	Student student3=newStudent(); 	student3.setId(3); 	student3.setName("小华"); 	student3.setAge(30); 	students.add(student3);
id name age
1 小余 18
2 小李 20
3 小华 30
boolean a = students.steam().anyMatch(item -> item.getAge() > 35)

a = false

boolean b = students.steam().anyMatch(item -> item.getAge() > 25)

b = true