Юрий Яхница :
I need to separate list of data into different lists by type, for this purpose I use construction
Map<String,List<Dish>> dishMap = menu.stream()
.collect(Collectors.groupingBy(Dish::getType));
but How can I get LinkedHashMap instead HashMap from method "Collectors.groupingBy". I found some data in javadoc but I can`t get what I must to do with this method:
Map<String,List<Dish>> dishMap = menu.stream().collect(Collectors.groupingBy(
Dish::getType,
LinkedHashMap::new, ????));
what should I place in the third argument in method "groupingBy" to get what I need?
Flown :
You should use the toList
Collector
:
Map<String,List<Dish>> dishMap = menu.stream().collect(Collectors.groupingBy(
Dish::getType,
LinkedHashMap::new, Collectors.toList()));
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=438045&siteId=1