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
  • 2,847
  • 7
  • 25
  • 34
Sachin Sachdeva
  • 10,744
  • 2
  • 45
  • 108

0 Answers0