allMatch函数
作用:Returns whether all elements of this stream match the provided predicate. 即判断是否所有的元素都匹配检查条件。
allMatch使用,代码如下:
package com.example.streamdemo;
import java.util.Arrays;
import java.util.List;
public class AnyMatchDemo {
public static void main(String[] args) {
List<String> list = Arrays.asList("java","c","Python");
boolean anyMatch = list.stream().anyMatch(obj->obj.endsWith("a"));
System.out.println(anyMatch);
}
}
复制
anyMatch函数
作用:Returns whether any elements of this stream match the provided. 即判断是否至少有一个元素匹配检查条件。
anyMatch使用,代码如下:
package com.example.streamdemo;
import java.util.Arrays;
import java.util.List;
public class AnyMatchDemo {
public static void main(String[] args) {
List<String> list = Arrays.asList("java","c","Python");
boolean anyMatch = list.stream().anyMatch(obj->obj.endsWith("a"));
System.out.println(anyMatch);
}
}
复制
最后修改时间:2020-07-01 13:35:48
文章转载自227decision,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
java项目选择云服务器怎么选?
云知识CLOUD
46次阅读
2025-04-09 20:02:37
Java萌新修炼手册⑥:面向对象の修仙奥义——从"散修"到"宗门大佬"的基因飞升!
让天下没有难学的编程
35次阅读
2025-04-25 10:10:40
Java数据库连接池学习
淡定
31次阅读
2025-04-14 22:46:26
从 Java 到 Go:面向对象的巨人与云原生的轻骑兵
京东云开发者
27次阅读
2025-04-25 11:41:37
Java萌新修炼手册⑤:数组の千层套路——从"鸽子笼"到"摩天楼"的进阶之路!
让天下没有难学的编程
26次阅读
2025-04-25 10:10:41
Java萌新修炼手册②:Hello Worldの108种写法——从入门到入坟!
让天下没有难学的编程
24次阅读
2025-04-21 10:34:36
Java萌新修炼手册④:流程控制の三十六计——让代码学会"见风使舵"!
让天下没有难学的编程
21次阅读
2025-04-23 14:33:55
Java萌新修炼手册①:开局一把JDK,环境搭建全靠浪!
让天下没有难学的编程
16次阅读
2025-04-21 10:34:37
【JVM祖传手艺大揭秘】双亲委派:Java世界的"啃老"生存法则
让天下没有难学的编程
16次阅读
2025-04-09 11:01:12
java浅拷贝BeanUtils.copyProperties引发的RPC异常
京东云开发者
15次阅读
2025-04-30 17:10:50