Grouping class has two errors with undefined functions at line 36 and 41
Opened this issue · 2 comments
private static Map<Dish.Type, Set> groupDishTagsByType() {
return menu.stream().collect(groupingBy(Dish::getType, flatMapping(dish -> dishTags.get( dish.getName() ).stream(), toSet())));
}
-> flatMapping shown as invalid and don't compile the class
private static Map<Dish.Type, List<Dish>> groupCaloricDishesByType() {
// return menu.stream().filter(dish -> dish.getCalories() > 500).collect(groupingBy(Dish::getType));
return menu.stream().collect(groupingBy(Dish::getType, filtering(dish -> dish.getCalories() > 500, toList())));
}
-> filtering shown as invalid and don't compile the class
This is because the source code was updated to Java 9.
takeWhile is a new method added to Stream interface in Java 9:
filtering and flatMapping where added to the Collectors interface:
This book's name is Java8InAcation. However the source has already updated to Java9.