Java 8 Streams Java Java API
Interface:
java.util.stream.LongStream
Method:
LongStream filter(LongPredicate predicate)
Returns a stream consisting of the elements of this stream that match the given predicate.
Examples
package com.logicbig.example.longstream;
import java.util.stream.LongStream;
public class FilterExample {
public static void main(String... args) { LongStream stream = LongStream.range(1, 20); stream.filter(FilterExample::odd) .forEach(System.out::println);
}
private static boolean odd(long lg) { return lg % 3 == 0; } }
Output3 6 9 12 15 18
|