educative.io

Combiner stream

Hi, please in this point what the benfit of using combiner could give me example because with the example above the result is same to the second point!!and for which reason or what the benfit when use Integer::sum in above example?

3. <U> U reduce(U identity, BiFunction<U, ? super T,U> accumulator, BinaryOperator<U> combiner)#

  int totalSum = list.parallelStream()
                .reduce(0, (partialSum, num) -> partialSum + num, Integer::sum);

Course: Educative: Interactive Courses for Software Developers
Lesson: Educative: Interactive Courses for Software Developers