It uses the Stream.sum reduction operation: Integer totalAge = roster .stream() .mapToInt(Person::getAge) .sum(); collect ( Collectors . Stream Elements with unique map keys – Collectors.toMap() If the stream elements have the unique map key field then we can use Collectors.toMap() to collect elements to map in Map