Given:
and
Which code fragment on line 1 makes the m map contain the employee with the highest salary for each neighborhood?
Given:
and
Which code fragment on line 1 makes the m map contain the employee with the highest salary for each neighborhood?
To create a map that contains the employee with the highest salary for each neighborhood, the correct code fragment should use the Collectors.groupingBy method to group employees by neighborhood, and within each group, collect the employee with the highest salary. The Collectors.groupingBy method creates a map where the key is the neighborhood and the value is the optional employee who has the maximum salary within that neighborhood. This is done using Collectors.maxBy with a Comparator that compares employees by salary. Option A correctly implements this logic.
answer: A B,D Fail there is no Collectors.maxBy with two paramenets C FAILED sorted in descending order
A is correct C is not correct Tested really
A tested. because it's asc sort default C is sort desc
c is the correct answer