In this example, you learned how to use the different reduce operations provided by Java streams. First, we used some specialized reduce operations provided by the DoubleStream, IntStream and LongStream classes. These operations allow you to count the number of elements of the stream, calculate the sum of all the elements of the stream, calculate the average value of the elements of the stream, and calculate the highest and lowest value of the elements of the stream. If you work with a generic Stream, you will only have the count() method to count the elements of the stream.
Then we used the three versions of the reduce() method provided by the Stream class. The first one receives only one parameter, a BinaryOperator. We specified ...