The last option should work. At least it should work semantically.
Yes, after trying to execute the code I did notice that a parenthesis was missing ) . But after you fix the parenthesis it just outputs the same as the first 2 choices.
But I believe we can't possible be expected to look for parenthesis in the OCP exam, right? Am I wrong to believe so?
See what I mean below:
Code that works:
Code: Select all
Set<String> newBooks = books
.stream()
.collect(Collectors.filtering(p, Collectors.mapping(Book::getTitle, Collectors.toSet())));
Code: Select all
Set<String> newBooks = books
.stream()
.collect(Collectors.filtering(p, Collectors.mapping(Book::getTitle, Collectors.toSet()));