17.3.2 Terminal Operations count, min, max, sum and average
Class IntStream
provides various terminal operations for common stream reductions on streams of int
values. Terminal operations are eager—they immediately process the items in the stream. Common reduction operations for IntStream
s include:
• count (line 19) returns the number of elements in the stream.
• min (line 21) returns the smallest int
in the stream.
• max (line 23) returns the largest int
in the stream.
• sum (line 24) returns the sum of all the int
s in the stream.
• average (line 26) returns an OptionalDouble (package java.util
) containing the average of the int
s in the stream as a value of type double
. For any stream, it’s possible that there are no elements in the stream. ...
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.