LongStream filter() in Java with examples
LongStream filter(LongPredicate 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.
LongStream filter(LongPredicate predicate) Where, LongStream is a sequence of primitive long-valued elements. LongPredicate represents a predicate (boolean-valued function) of one long-valued argument and the function returns the new stream.
Example 1 : filter() method on LongStream.
Example 2 : filter() method on LongStream.
My Personal Notes arrow_drop_up
Please Login to comment...