我还不熟悉
Java中的lambda表达式.
能够
//create a comparator object using a Lambda expression
Comparator compareDouble = (d1, d2) -> d1.compareTo(d2);
//Sort the Collection in this case 'testList' in reverse order
Collections.sort(testList, Collections.reverseOrder(compareDouble));
在没有显式创建变量compareDouble的情况下编写?
我尝试了以下,但为什么它不起作用?
//Sort the Collection in this case 'testList' in reverse order
Collections.sort(testList, Collections.reverseOrder(new Comparator ((d1, d2) -> d1.compareTo(d2))));
谢谢.