I want to sum a list of Integers. It works as follows, but the syntax does not feel right. Could the code be optimized?

Map<String, Integer> integers;
integers.values().stream().mapToInt(i -> i).sum();

12 Answers
12

Leave a Reply

Your email address will not be published. Required fields are marked *