Java中的IntStream noneMatch()方法
noneMatch()Java中的方法返回此流中是否没有元素与提供的谓词匹配。如果流中没有元素与提供的谓词匹配或流为空,则返回布尔值true。
语法如下
Boolean noneMatch(IntPredicate predicate)
在这里,参数谓词是应用于该流元素的无状态谓词
创建一个IntStream
IntStream intStream = IntStream.of(15, 25, 50, 60, 80, 100, 130, 150);
在这里,设置一个条件,该条件返回此流中是否没有元素与提供的谓词匹配。我们正在检查所有值都不小于10
boolean res = intStream.noneMatch(a -> a < 10);
以下是noneMatch()在Java中实现IntStream方法的示例。它检查是否没有元素
示例
import java.util.*;
import java.util.stream.IntStream;
public class Demo {
public static void main(String[] args) {
IntStream intStream = IntStream.of(15, 25, 50, 60, 80, 100, 130, 150);
boolean res = intStream.noneMatch(a -> a < 10);
System.out.println(res);
}
}输出结果
true
热门推荐
10 圣诞祝福语简短小学
11 祖国七十华诞简短祝福语
12 老师送的祝福语简短
13 生日祝福语大全女生简短
14 祝女性生日祝福语简短
15 牛年女神节祝福语简短
16 情人表白祝福语简短大气
17 老公开业祝福语简短
18 官宣新年祝福语简短