Summing elements in a stream of integers is done by converting to an IntStream with mapToInt, then calling its sum() terminal operation.
Given the list [1, 2, 3, 4, 5], converting to an IntStream and calling sum() produces 15.
int sum = numbers.stream()
.mapToInt(Integer::intValue)
.sum();A concise interview answer is
I convert the boxed stream to a primitive IntStream with mapToInt(Integer::intValue), then call sum(), which avoids the boxing overhead of using reduce(0, Integer::sum) directly on a Stream<Integer> and gives access to other numeric aggregates like average() and max().
Last updated: 11 November 2026
Previous question: How do you find the maximum value in a list using Java streams?
Next question: How do you convert a list of names to uppercase using Java streams?