Java Professional — Medium
Key points
- The reduce method combines all elements of the stream into a single result.
- The `Integer::sum` method reference is used to perform the sum operation.
- The initial value of 0 is added to the sum of the elements.
- The correct answer is 6, which is the sum of 1, 2, and 3.
Ready to go further?
Related questions
