package .;
import ;
import ;
import ;
import ;
import ;
/**
* 使用Lambda排序
*
* @author xiaowen0623
*
*/
public class LambdaSort {
public static void main(String[] args) {
List<String> names = ("peter", "anna", "mike", "wbw");
// 第一种排序方式
(names, new Comparator<String>() {
@Override
public int compare(String a, String b) {
return (b);
}
});
// 第二种
(names, (String a, String b) -> {
return (a);
});
// 第三种
(names, (a, b) -> (a));
(names);
List<String> names2 = ("peter", null, "anna", "mike", "xenia");
((String::compareTo));
(names2);
List<String> names3 = null;
(names3).ifPresent(list -> (()));
(names3);
}
}