IntStream noneMatch() method in Java


The noneMatch() method in Java returns whether no elements of this stream match the provided predicate. The true boolean value is returned if either no elements of the stream match the provided predicate or the stream is empty.

The syntax is as follows

Boolean noneMatch(IntPredicate predicate)

Here, parameter predicate is the stateless predicate to apply to elements of this stream

Create an IntStream

IntStream intStream = IntStream.of(15, 25, 50, 60, 80, 100, 130, 150);

Here, set a condition that returns whether no elements of this stream match the provided predicate. We are checking for none of the value less than 10

boolean res = intStream.noneMatch(a -> a < 10);

The following is an example to implement IntStream noneMatch() method in Java. It checks whether no element

Example

 Live Demo

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);
   }
}

Output

true

Updated on: 30-Jul-2019

582 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements