I have map with key as String and value as List. List can have 10 unique values. I need to convert this map with key as Integer and value as List. Example as below :
You can Achieve in this way
Let suppose I have Person class with Gender and Age . I want to get it in this form
Map>
I would write simply
Map> map = personList.stream()
.collect(Collectors.groupingBy(Person::getGender));
it will get me something like below (one key against multiple values )
key:MALE
age31sexMALE
age28sexMALE
key:FEMALE
age40sexFEMALE
age44sexFEMALE