Try:
Map<Integer, Long> counters = persons.stream()
.collect(Collectors.groupingBy(p -> p.getBirthday().getMonthValue(),
Collectors.counting()));
Related Contents:
- Is it possible to use Java 8 for Android development?
- In Java streams is peek really only for debugging?
- When to use: Java 8+ interface default method, vs. abstract method
- Removal of JDBC ODBC bridge in java 8
- How to serialize a lambda?
- What is the equivalent lambda expression for System.out::println
- How to convert an Iterator to a Stream?
- org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15
- Why is the max recursion depth I can reach non-deterministic?
- Java 8: Lambda-Streams, Filter by Method with Exception
- Calculate days between two Dates in Java 8
- Generic type inference not working with method chaining?
- Android Studio Error: Error:CreateProcess error=216, This version of %1 is not compatible with the version of Windows you’re running
- Java 8: Difference between method reference Bound Receiver and UnBound Receiver
- Any difference between java.time.Clock.systemDefaultZone().getZone() vs java.util.TimeZone.getDefault().toZoneId()?
- Java 8 Lambda Expressions – what about multiple methods in nested class
- Why java.util.Optional is not Serializable, how to serialize the object with such fields
- Parallel streams, collectors and thread safety
- How does Java 8′ new default interface model works (incl. diamond, multiple inheritance, and precedence)?
- In Java, how do I efficiently and elegantly stream a tree node’s descendants?
- Differences between Java 8 Date Time API (java.time) and Joda-Time
- How to get milliseconds from LocalDateTime in Java 8
- What’s the difference between instance method reference types in Java 8?
- Why is “final” not allowed in Java 8 interface methods?
- Java 8, Streams to find the duplicate elements
- Can a Collector’s combiner function ever be used on sequential streams?
- No IDEA annotations attached to the JDK 1.8 (C:\…), some issues will not be found
- In Java Lambda’s why is getClass() called on a captured variable
- Performance difference between Java 8 lambdas and anonymous inner classes
- What does “an Arbitrary Object of a Particular Type” mean in java 8?
- comparing and thenComparing gives compile error
- Why should I use concurrent characteristic in parallel stream with collect?
- null-safe mapping Comparator using default implementations
- Java Streams – How to group by value and find min and max value of each group?
- Why does this java 8 stream operation evaluate to Object instead of List or just List?
- Recursive ConcurrentHashMap.computeIfAbsent() call never terminates. Bug or “feature”?
- Mock Instant.now() without using Clock into Constructor or without Clock Object
- Java 8 method references: provide a Supplier capable of supplying a parameterized result
- Eclipse + Java 8 support?
- Why are interfaces in Java 8 allowed to have the main method?
- In Stream reduce method, must the identity always be 0 for sum and 1 for multiplication?
- Modifying Objects within stream in Java8 while iterating
- Optional vs. null. What is the purpose of Optional in Java 8? [duplicate]
- How to get a Stream from a float[]
- Comparator.comparing(…) of a nested field
- Format a date using the new date time API
- How to debug stream().map(…) with lambda expressions?
- How to work around the stricter Java 8 Javadoc when using Maven
- Java 8 peek vs map
- How to implement a Java stream?