Mutable Reduction Through reduce()

In this lesson, you will learn about immutable reduction using the reduce() method.

Introduction to reduction operations

Reduction stream operations are those operations that reduce the stream into a single value. The operations that we are going to discuss in this lesson are immutable operations because they reduce the result into a single-valued immutable variable. Given a collection of objects, we may need to get the sum of all the elements, the max element, or any other operation which gives us a single value as a result. This can be achieved through reduction operations.

Before we discuss all the reduction operations in detail, let’s first look at some key concepts of reduction:

  1. Identity – an ...