Skip to content

Tag Archives: Java-Stream interface

Stream builder() returns a builder for a Stream. Syntax : static <T> Stream.Builder<T> builder() where, T is the type of elements. Return Value : A… Read More
Stream empty() creates an empty sequential Stream. Syntax : static <T> Stream<T> empty() Parameters : T : The type of stream elements. Stream : A… Read More
Stream toArray() returns an array containing the elements of this stream. It is a terminal operation i.e, it may traverse the stream to produce a… Read More
Stream mapToLong(ToLongFunction mapper) returns a LongStream consisting of the results of applying the given function to the elements of this stream. Stream mapToLong(ToLongFunction mapper) is… Read More
Stream findAny() returns an Optional (a container object which may or may not contain a non-null value) describing some element of the stream, or an… Read More
Stream forEachOrdered(Consumer action) performs an action for each element of this stream, in the encounter order of the stream if the stream has a defined… Read More
Stream forEach(Consumer action) performs an action for each element of the stream. Stream forEach(Consumer action) is a terminal operation i.e, it may traverse the stream… Read More
Stream allMatch(Predicate predicate) returns whether all elements of this stream match the provided predicate. It may not evaluate the predicate on all elements if not… Read More
Stream anyMatch(Predicate predicate) returns whether any elements of this stream match the provided predicate. It may not evaluate the predicate on all elements if not… Read More
Stream noneMatch(Predicate predicate) returns whether no elements of this stream match the provided predicate. It may not evaluate the predicate on all elements if not… Read More
In Java 8, there is predefined counting() method returned by Collectors class counting() method to count the number of elements in a Stream. Syntax :… Read More
Stream filter(Predicate predicate) returns a stream consisting of the elements of this stream that match the given predicate. This is an intermediate operation. These operations… Read More
Stream findFirst() returns an Optional (a container object which may or may not contain a non-null value) describing the first element of this stream, or… Read More
Stream flatMapToInt(Function mapper) returns an IntStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced… Read More
Stream mapToInt(ToIntFunction mapper) returns an IntStream consisting of the results of applying the given function to the elements of this stream. Stream mapToInt(ToIntFunction mapper) is… Read More