- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
DoubleStream anyMatch() method in Java
The anyMatch() method of the DoubleStream class returns whether any elements of this stream match the provided predicate.
The syntax is as follows
boolean anyMatch(DoublePredicate predicate)
Here, the parameter predicate is a stateless predicate to apply to elements of this stream. The DoublePredicate here is a predicate of one double-valued argument.
To use the DoubleStream class in Java, import the following package
import java.util.stream.DoubleStream;
Create a DoubleStream and add some elements to the stream
DoubleStream doubleStream = DoubleStream.of(67.9, 89.9, 10.5, 95.8, 49.6);
Now, check if any of the elements match the predicate
boolean res = doubleStream.anyMatch(a -> a > 50);
The following is an example to implement DoubleStream anyMatch() method in Java
Example
import java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) { DoubleStream doubleStream = DoubleStream.of(67.9, 89.9, 10.5, 95.8, 49.6); boolean res = doubleStream.anyMatch(a -> a > 50); System.out.println("Do any element match the predicate? "+res); } }
Output
Do any element match the predicate? True
Advertisements