DoubleStream filter(DoublePredicate predicate) example
Description
DoubleStream filter(DoublePredicate predicate)
returns
a stream that matches the given predicate.
This is an intermediate operation.
Syntax
filter
has the following syntax.
DoubleStream filter(DoublePredicate predicate)
Example
The following example shows how to use filter
.
import java.util.stream.DoubleStream;
/*w w w .j a v a 2 s . c om*/
public class Main {
public static void main(String[] args) {
DoubleStream d = DoubleStream.of(1.2,2.3,4.5);
d.filter(n -> n<3)
.forEach(System.out::println);
}
}
The code above generates the following result.