answer : B
CD will work as well if stream() is inserted in like:
.get(true)
.stream()
.count();
---------------
Predicate < Employee > p = e -> e.getSalary() > 25;
LocalDate d = IsoChronology.INSTANCE.date(1989, 1, 1);
Predicate < Employee > p1 = e -> e.getBirthday().isAfter(d);
Stream < Employee > s = roster.stream();
Map < Boolean, List < Employee >> youngerThan =
s.filter(p).collect(Collectors.partitioningBy(e -> e.getBirthday().isAfter(d)));
long youngAndRich = youngerThan.get(true).stream().count();
B is correct, Stream has count method
d Collectors.partitioningBy(predicated) generate a map with two keys true, and false, and values has the list of the predicated definied.
but List hasn't count method, if used a size this is true
B is correct.
Incorrect -> A: e is not defined.
Incorrect -> C and D. get(true) returns a stream so it would work if you add
.get(true).stream().count()
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
ASPushkin
2 months, 1 week agod7bb0b2
6 months agod7bb0b2
6 months agod7bb0b2
7 months agodilleman
9 months, 2 weeks agodilleman
9 months, 2 weeks ago