DoubleStream filter() in Java with examples
DoubleStream filter(DoublePredicate predicate) returns a stream consisting of the elements of this stream that match the given predicate. This is an intermediate operation. These operations are always lazy i.e, executing an intermediate operation such as filter() does not actually perform any filtering, but instead creates a new stream that, when traversed, contains the elements of the initial stream that match the given predicate.
DoubleStream filter(DoublePredicate predicate)
- DoubleStream : A sequence of primitive double-valued elements.
- DoublePredicate : A predicate (boolean-valued function) of one double-valued argument.
Return Value : The function returns the new stream.
Example 1 : filter() method on DoubleStream.
6.6 8.1 9.7
Example 2 : filter() method on DoubleStream.
5.4 6.6 8.1 9.7
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.