LongStream filter(LongPredicate predicate)
returns a stream consisting of the elements of this stream that match the given predicate.
This is an intermediate operation.
filter
has the following syntax.
LongStream filter(LongPredicate predicate)
The following example shows how to use filter
.
import java.util.stream.LongStream; // w ww .j a v a2s . co m public class Main { public static void main(String[] args) { LongStream b = LongStream.of(1L, 2L, 3L, 4L); b.filter(l -> l % 2 == 0); b.forEach(System.out::println); } }