585799 (1) [Avatar] Offline
#1
I downloaded the source codes for Java 8 in Action.

Grouping.java at src/main/java/lambdasinaction/chap6 has compilation problem.
Fixing it to:
private static Map<Dish.Type, Set<String>> groupDishTagsByType() {
return menu.stream().collect(groupingBy(Dish::getType, flatMap(dish -> dishTags.get( dish.getName() ).stream(), toSet())));
}

has this compilation problem:

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method flatMap((<no type> dish) -> {}, toSet()) is undefined for the type Grouping

at lambdasinaction.chap6.Grouping.groupDishTagsByType(Grouping.java:36)
at lambdasinaction.chap6.Grouping.main(Grouping.java:16)


Please help.
Thanks.
java version: "1.8.0_172"
bruno_bravo (8) [Avatar] Offline
#2