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 教师闺蜜祝福语简短