

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 anyMatch() method in Java
The anyMatch() method of the LongStream class in Java returns whether any elements of this stream match the provided predicate.
The syntax is as follows.
boolean anyMatch(LongPredicate predicate)
Here, the parameter predicate is the stateless predicate to apply to elements of this stream. The LongPredicate represents a predicate of one long-valued argument.
To use the LongStream class in Java, import the following package.
import java.util.stream.LongStream;
The following is an example to implement LongStream anyMatch() method in Java.
Example
import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream longStream = LongStream.of(100L, 150L, 200L, 300L, 400L, 500L); boolean res = longStream.anyMatch(a -> a > 350L); System.out.println("Do any of the element match the predicate? "+res); } }
Here is the output. It returns TRUE since atleast one of the element match the predicate mentioned in the anyMatch() method.
Output
Do any of the element match the predicate? true
- Related Questions & Answers
- IntStream anyMatch() method in Java
- DoubleStream anyMatch() method in Java
- LongStream noneMatch() method in Java
- LongStream filter() method in Java
- LongStream forEach() method in Java
- LongStream max() method in Java
- LongStream rangeClosed() method in Java
- LongStream peek() method in Java
- LongStream empty() method in Java
- LongStream findFirst() method in Java
- LongStream of() method in Java
- LongStream toArray() method in Java
- LongStream summaryStatistics() method in Java
- LongStream boxed() method in Java
- LongStream sorted() method in Java
Advertisements