allMatch函数:

检查是否匹配所有元素,只有全部符合才返回true
boolean flag = list.stream().allMatch(obj->obj.length()>5);
 
anyMatch函数
检查是否⾄少匹配⼀个元素,只要有一个符合就返回true
boolean flag = list.stream().anyMatch(obj->obj.length()>18);
 
max函数
list.stream().max(Comparator.comparingInt(Student::getAge));
 
min函数
Optional<Student> optional = list.stream().min((s1, s2)->Integer.compare(s1.getAge(),s2.getAge()));

相关文章:

  • 2021-07-06
  • 2021-07-14
  • 2021-11-18
  • 2022-02-04
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2022-02-17
猜你喜欢
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
  • 2021-12-12
  • 2022-01-14
相关资源
相似解决方案