Core concept
int sum = list.stream().mapToInt(Integer::intValue).sum();
int prod = list.stream().reduce(1, (a, b) -> a * b);Advertisement
How it works
reduce identity for empty stream.
Advertisement
Trade-offs + gotchas
Every stream pipeline.