Stream流的noneMatch()
方法返回此流中是否没有元素与提供的谓词匹配。
如果流中没有元素匹配提供的谓词,或者流为空,则该方法返回true。
比如:
Stream stream = Stream.of(1,2,3,4);
boolean b = stream.noneMatch(s -> (int)s>4);
System.out.println("返回结果-----" + b); //true
例子中,流里面没有大于4的元素,返回true;
Stream流的noneMatch()
方法返回此流中是否没有元素与提供的谓词匹配。
如果流中没有元素匹配提供的谓词,或者流为空,则该方法返回true。
比如:
Stream stream = Stream.of(1,2,3,4);
boolean b = stream.noneMatch(s -> (int)s>4);
System.out.println("返回结果-----" + b); //true
例子中,流里面没有大于4的元素,返回true;