Comment Comment by _old_dude_ yes, Java 8 adds a bunch of methods to ArrayList and HashMap that makes the code a little more high level.There is also another variation, using map.getOrDefault() words.forEach(word -> { map.put(word, map.getOrDefault(word, 0) + 1); }); and then at some points you discover the Stream API var map = words.stream().collect(Collectors.groupingBy(w -> w, Collectors.counting())); parent _old_dude_ 7 years ago
There is also another variation, using map.getOrDefault()
and then at some points you discover the Stream API