How to use groupingBy Collector in Java Streams

groupingBy is similar to GROUP BY of SQL since it groups and collects the objects based…