The reduce() method is a terminal operation that aggregates stream elements into a single result based on a provided identity and accumulator function.
Source Code
List numbers = Arrays.asList(1, 2, 3, 4, 5);
int sum = numbers.stream().reduce(0, Integer::sum);
System.out.println("Sum: " + sum); // Outputs: 15