这篇文章主要介绍了java的Match怎么使用的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇java的Match怎么使用文章都会有所收获,下面我们一起来看看吧。
概念
1、各种Match操作可用于判断给定的Predicate是否符合Stream的要素。
2、Match操作是终端操作,返回布尔值。
实例
boolean anyStartsWithA = stringCollection .stream() .anyMatch((s) -> s.startsWith("a")); System.out.println(anyStartsWithA); // true boolean allStartsWithA = stringCollection .stream() .allMatch((s) -> s.startsWith("a")); System.out.println(allStartsWithA); // false boolean noneStartsWithZ = stringCollection .stream() .noneMatch((s) -> s.startsWith("z")); System.out.println(noneStartsWithZ); // true
关于“java的Match怎么使用”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“java的Match怎么使用”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注本站行业资讯频道。