0

Following streams produces the same result however there are two different ways to achieve this.

Person.stream().map(Person::getAge).reduce(Integer::sum).get();

Person.stream().mapToInt( Person::getAge).sum();

I want to know difference among two and which one is better.

Stefan Zobel
  • 3,182
  • 7
  • 28
  • 38
T-Bag
  • 10,916
  • 3
  • 54
  • 118

0 Answers0