Collections.sort(names, (String a, String b) -> { return b.compareTo(a); }); 正如你可以看到的代码更容易阅读。但它甚至更短: Collections.sort(names, (String a, String b) -> b.compareTo(a)); 一行方法的方法体可以跳过{}和参数类型,使它变得更短: Collections.sort(names, (a, b) -> b.compareTo(a));
https://yq.aliyun.com/articles/17036?spm=a2c4e.11153940.0.0.6a255562myIiAj