17.4.1 Creating a Stream<Integer>
When you pass an array of objects to class Arrays
’s static
method stream
, the method returns a Stream
of the appropriate type—e.g., line 19 produces a Stream<Integer>
from an Integer
array. Interface Stream (package java.util.stream
) is a generic interface for performing stream operations on any non-primitive type. The types of objects that are processed are determined by the Stream
’s source.
Class Arrays
also provides overloaded versions of method stream
for creating IntStream
s, LongStream
s and DoubleStream
s from entire int
, long
and double
arrays or from ranges of elements in the arrays. The specialized IntStream
, LongStream
and DoubleStream
classes provide various methods for common operations on numerical ...
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.