Try:
Map<Integer, Long> counters = persons.stream()
.collect(Collectors.groupingBy(p -> p.getBirthday().getMonthValue(),
Collectors.counting()));
More Related Contents:
- Should Java 8 getters return optional type?
- Convert Iterable to Stream using Java 8 JDK
- Java 8 Streams: multiple filters vs. complex condition
- Java 8 stream reverse order
- Partition a Java 8 Stream
- Convert from List to CompletableFuture
- Lambda ‘special void-compatibility rule’ – statement expression
- Instance Method Reference and Lambda Parameters
- Why is this java Stream operated upon twice?
- Modifying local variable from inside lambda
- Java 8 Streams – collect vs reduce
- How can I get a List from some class properties with Java 8 Stream?
- Why doesn’t java.util.Collection implement the new Stream interface?
- Stream Filter of 1 list based on another list
- In Java 8, why is the default capacity of ArrayList now zero?
- Why are class static methods inherited but not interface static methods?
- Why does this java 8 stream operation evaluate to Object instead of List or just List?
- Optional vs. null. What is the purpose of Optional in Java 8? [duplicate]
- In Stream reduce method, must the identity always be 0 for sum and 1 for multiplication?
- How do I access a UI element from another controller class in JavaFX?
- Comparator.comparing(…) of a nested field
- Using JavaFX in JRE 8, “Access restriction” error
- Why Functional Interfaces in Java 8 have one Abstract Method?
- Annotating the functional interface of a Lambda Expression
- Java Lambda expressions [closed]
- Are defaults in JDK 8 a form of multiple inheritance in Java?
- How to implement a Java stream?
- Why didn’t Stream have a toList() method?
- Are Java 8 lambdas compiled as inner classes, methods or something else? [duplicate]
- non-interference requirement on Java 8 streams