Given:
What is the result?
Given:
What is the result?
The code creates an array of cat names and then adds those names to an ArrayList. It sorts the ArrayList in descending order using the lambda expression `(var a, var b) -> -a.compareTo(b)`, where the minus sign reverses the natural order of comparison. Finally, it prints each element of the sorted list. The correct result is the cat names in descending alphabetical order: sphynx, oxicat, laperm, korat, bengal, abyssinian.
The default sort order is ascending. The line -a.compareTo(b) changes the order to descending. The answer is: C
C is correct TESTED
Tested: C.
Answer:C
interesting thing : var cats = new ArrayList<>(Arrays.asList(catNames)); Diamond Operator - compiler's type inference feature determines the most suitable constructor declaration that matches the invocation. This is not a row type.
C is corrrect the sort is inversed -a.compareTo(b)
C is correct