Please see the code below, on the fourth line, put the lambda expression in the .sort() method, it works fine.
The fifth line, using Arrays.sort() will report an error. I would like to know where is the difference between the two. and how to properly use lambda expressions in Arrays.sort()
var strs = new ArrayList<String>();
strs.add("AA");
strs.add("BB");
strs.sort((a,b) -> b.compareTo(a)); // OK
// Arrays.sort(strs, (a, b) -> b.compareTo(a) ); // CAN NOT COMPILE java: no suitable method found for sort...
Related questions: using Arrays.sort with Lambda
Arrays.sortmust be an array, you passed aList.Arrayswith collections. Probably you need this insteadCollections.sort(strs, (a, b) -> b.compareTo(a));