The Stream.reduce performs a reduction on the elements of the stream returning OptionalDouble. The operation allows you to combine elements of a stream to express complicated queries such as "calculate the total precipication for the year" or "when did the most precipication occur".

The example below will find the total amount (sum) of precipitation for the given stream. In the past while trying to calculate sum values in a list or summing values in array, the elements had to be combined iteratively. The stream.reduce approach is processed internally which makes for much cleaner code.

max

Stream.max is another reduction operation which is processed internally and is similar to finding max value in array or max value from list. The example below will find the date with the highest precipitation.

Stream.average will calculate the average value of an Integer property of the items in the Stream. This operation similar to calculate average of values in array or calculate average of values in collection but processed internally not iteratively. The example below will find the avareage of preciptiation across all entries in the stream.

count

Stream.count will count the number of elements in a stream. This operation is similar to counting elements in list. The example below will count the total number of elements in the precip stream.