Complete the code to sort the employees collection by salary using a Comparator.Assume the method getSalary that returns an employee's salary as an integer.
Collections.sort(employees, _____________________________________) ;
A) Comparator.comparing(Employee::getSalary)
B) Comparator.comparing(Employee::getSalary() )
C) Comparator.thenComparing(Employee::getSalary)
D) Comparator.comparing(e -> e.getSalary)
Correct Answer:
Verified
Q40: Complete the following code snippet that returns
Q41: A _ operation triggers the lazy operations
Q42: Which lambda expression represents a function that
Q43: Complete the following code snippet that displays
Q44: The method reference System.out::println is a shorthand
Q46: Complete the following code snippet that returns
Q47: What does the following lambda expression do,
Q48: The constructor reference Student[]::new is a shorthand
Q49: Which statement about higher-order functions is NOT
Q50: Complete the following code snippet that checks
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents