Stream (Java SE 25 & JDK 25)
- Type Parameters:
T- the type of the stream elements
- All Superinterfaces:
AutoCloseable, BaseStream<T, Stream<T>>
-
Nested Class Summary
Nested Classes
static interfaceA mutable builder for a
Stream. -
Method Summary
booleanReturns whether all elements of this stream match the provided predicate.
booleanReturns whether any elements of this stream match the provided predicate.
builder()Returns a builder for a
Stream.<R> R<R,A> R Performs a mutable reduction operation on the elements of this stream using a
Collector.Creates a lazily concatenated stream whose elements are all the elements of the first stream followed by all the elements of the second stream.
longcount()Returns the count of elements in this stream.
distinct()Returns a stream consisting of the distinct elements (according to
Object.equals(Object)) of this stream.Returns, if this stream is ordered, a stream consisting of the remaining elements of this stream after dropping the longest prefix of elements that match the given predicate.
empty()Returns an empty sequential
Stream.Returns a stream consisting of the elements of this stream that match the given predicate.
findAny()Returns an
Optionaldescribing some element of the stream, or an emptyOptionalif the stream is empty.Returns an
Optionaldescribing the first element of this stream, or an emptyOptionalif the stream is empty.flatMap(Function<? super T, ? extends Stream<? extends R>> mapper) Returns a stream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
Returns an
DoubleStreamconsisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.Returns an
IntStreamconsisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.Returns an
LongStreamconsisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.voidPerforms an action for each element of this stream.
voidPerforms an action for each element of this stream, in the encounter order of the stream if the stream has a defined encounter order.
gather(Gatherer<? super T, ?, R> gatherer) Returns a stream consisting of the results of applying the given
Gathererto the elements of this stream.Returns an infinite sequential unordered stream where each element is generated by the provided
Supplier.Returns a sequential ordered
Streamproduced by iterative application of the givennextfunction to an initial element, conditioned on satisfying the givenhasNextpredicate.Returns an infinite sequential ordered
Streamproduced by iterative application of a functionfto an initial elementseed, producing aStreamconsisting ofseed,f(seed),f(f(seed)), etc.limit(long maxSize) Returns a stream consisting of the elements of this stream, truncated to be no longer than
maxSizein length.map(Function<? super T, ? extends R> mapper) Returns a stream consisting of the results of applying the given function to the elements of this stream.
Returns a stream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements.
Returns a
DoubleStreamconsisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements.Returns an
IntStreamconsisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements.Returns a
LongStreamconsisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements.Returns a
DoubleStreamconsisting of the results of applying the given function to the elements of this stream.Returns an
IntStreamconsisting of the results of applying the given function to the elements of this stream.Returns a
LongStreamconsisting of the results of applying the given function to the elements of this stream.Returns the maximum element of this stream according to the provided
Comparator.Returns the minimum element of this stream according to the provided
Comparator.booleanReturns whether no elements of this stream match the provided predicate.
of(T t) Returns a sequential
Streamcontaining a single element.of(T... values) Returns a sequential ordered stream whose elements are the specified values.
ofNullable(T t) Returns a sequential
Streamcontaining a single element, if non-null, otherwise returns an emptyStream.Returns a stream consisting of the elements of this stream, additionally performing the provided action on each element as elements are consumed from the resulting stream.
Performs a reduction on the elements of this stream, using an associative accumulation function, and returns an
Optionaldescribing the reduced value, if any.Performs a reduction on the elements of this stream, using the provided identity value and an associative accumulation function, and returns the reduced value.
<U> UPerforms a reduction on the elements of this stream, using the provided identity, accumulation and combining functions.
skip(long n) Returns a stream consisting of the remaining elements of this stream after discarding the first
nelements of the stream.sorted()Returns a stream consisting of the elements of this stream, sorted according to natural order.
Returns a stream consisting of the elements of this stream, sorted according to the provided
Comparator.Returns, if this stream is ordered, a stream consisting of the longest prefix of elements taken from this stream that match the given predicate.
toArray()Returns an array containing the elements of this stream.
<A> A[]Returns an array containing the elements of this stream, using the provided
generatorfunction to allocate the returned array, as well as any additional arrays that might be required for a partitioned execution or for resizing.toList()Accumulates the elements of this stream into a
List.
-
Method Details
-
filter
-
map
-
mapToInt
-
mapToLong
-
mapToDouble
-
flatMap
-
flatMapToInt
-
flatMapToLong
-
flatMapToDouble
-
mapMulti
-
mapMultiToInt
-
mapMultiToLong
-
mapMultiToDouble
-
distinct
-
sorted
-
sorted
-
peek
-
limit
-
skip
-
takeWhile
-
dropWhile
-
forEach
-
forEachOrdered
-
toArray
-
toArray
-
reduce
-
reduce
-
reduce
-
gather
-
collect
-
collect
-
toList
-
min
-
max
-
count
-
anyMatch
-
allMatch
-
noneMatch
-
findFirst
-
findAny
-
builder
-
empty
-
of
-
ofNullable
-
of
-
iterate
-
iterate
-
generate
-
concat
-