reduce() is a general-purpose terminal Stream operation that combines all elements into a single result using an identity value and an accumulator function.
Given the list [1, 2, 3, 4], calling reduce(0, Integer::sum) folds the elements together starting from 0, producing a total of 10.
int total = numbers.stream()
.reduce(0, Integer::sum);A concise interview answer is
reduce(identity, accumulator) folds a stream down to a single value, starting from the identity and combining elements one at a time with the accumulator function. For summing integers, reduce(0, Integer::sum) is equivalent to using an IntStream's sum(), just more general-purpose.
Last updated: 11 November 2026
Previous question: How do you get distinct elements from a list using Java streams?
Next question: How does findAny() work in Java streams?