Check out example codes for "group elements in list with some attributes". It will help you in understanding the concepts better.

Code Example 1

Map<String, List<Student>> studlistGrouped =
    studlist.stream().collect(Collectors.groupingBy(w -> w.stud_location));

Learn ReactJs, React Native from akashmittal.com