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 婆婆高寿祝福语大全简短