How to use groupingBy Collector in Java Streams

Stream API's groupingBy is similar to GROUP BY of SQL since it groups and collects the…