publicstaticvoidallMatch(){
List<User> list =users();boolean flag = list.stream().allMatch(user -> user.getAge()>=16);
System.out.println(flag);}
9.anyMatch(T->boolean)检测是否有任意元素满足给定的条件
publicstaticvoidanyMatch(){
List<User> list =users();boolean flag = list.stream().anyMatch(user -> user.getSex()==1);
System.out.println(flag);}
10.noneMatchT->boolean)流中是否有元素匹配给定的 T -> boolean条件
publicstaticvoidnoneMatch(){
List<User> list =users();boolean flag = list.stream().noneMatch(user -> user.getAddress().contains("万毒窟"));
System.out.println(flag);}
11.findFirst( ):找到第一个元素
publicstaticvoidfindfirst(){
List<User> list =users();
Optional<User> optionalUser = list.stream().sorted(Comparator.comparingInt(User::getAge)).findFirst();
System.out.println(optionalUser.toString());}
12.findAny( ):找到任意一个元素
publicstaticvoidfindAny(){
List<User> list =users();
Optional<User> optionalUser = list.stream().findAny();
System.out.println(optionalUser.toString());}
13.计算总数
publicstaticvoidcount(){
List<User> list =users();long count = list.stream().count();
System.out.println(count);}
14.最大值最小值
publicstaticvoidmax_min(){
List<User> list =users();
Optional<User> max = list.stream().collect(
Collectors.maxBy(
Comparator.comparing(User::getAge)));
Optional<User> min = list.stream().collect(
Collectors.minBy(
Comparator.comparing(User::getAge)));
System.out.println("max--> "+ max+" min--> "+ min);}