DoubleStream noneMatch() method in Java

Java 8ProgrammingObject Oriented Programming

The noneMatch() method of the DoubleStream class returns true if none of the elements of this stream match the provided predicate.

The syntax is as follows

boolean noneMatch(DoublePredicate predicate)

Here, predicate is a stateless predicate to apply to elements of this stream. To use the DoubleStream class in Java, import the following package

import java.util.stream.DoubleStream;

Create DoubleStream and add some elements to the stream

DoubleStream doubleStream = DoubleStream.of(15.8, 28.7, 35.7, 48.1, 78.9);

Now, TRUE is returned if none of the element match the condition

boolean res = doubleStream.noneMatch(num -> num > 90);

The following is an example to implement DoubleStream noneMatch() method in Java

Example

 Live Demo

import java.util.*;
import java.util.stream.DoubleStream;
public class Demo {
   public static void main(String[] args) {
      DoubleStream doubleStream = DoubleStream.of(15.8, 28.7, 35.7, 48.1, 78.9);
      boolean res = doubleStream.noneMatch(num -> num > 90);
      System.out.println("Do any of the element match the predicate? "+res);
   }
}

Output

Do any of the element match the predicate? True
raja
Published on 26-Mar-2019 14:48:45
Advertisements