
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
LongStream noneMatch Method in Java
The noneMatch() method of the LongStream class in Java returns whether no elements of this stream match the provided predicate.
The syntax is as follows
boolean noneMatch(LongPredicate predicate)
Here, the parameter predicate is a stateless predicate to apply to elements of this stream. However, LongPredicate in the syntax represents a predicate (boolean-valued function) of one long-valued argument.
To use the LongStream class in Java, import the following package
import java.util.stream.LongStream;
The method returns true if either no elements of the stream match the provided predicate or the stream is empty. The following is an example to implement LongStream noneMatch() method in Java
Example
import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream longStream = LongStream.of(10L, 20L, 30L, 40L); boolean res = longStream.noneMatch(a -> a > 50); System.out.println("None of the element match the predicate? "+res); } }
True is returned since none of the element match the predicate
Output
None of the element match the predicate? true
Example
import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream longStream = LongStream.of(10L, 20L, 30L, 40L, 50, 60L); boolean res = longStream.noneMatch(a -> a < 30L); System.out.println("None of the element match the predicate? "+res); } }
False is returned since one or more than one element match the predicate
Output
None of the element match the predicate? False
Advertisements