-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test.java
42 lines (35 loc) · 861 Bytes
/
Test.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
*
*/
package net.zhangwenbo;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* @author iver3on
* @email [email protected]
*/
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
List<String> names = Arrays.asList("peter", "anna", "mike", "xenia");
/*
* Collections.sort(names, new Comparator<String>() {
@Override
public int compare(String a, String b) {
return b.compareTo(a);
}
});
*/
//JAVA8Lambda±í´ïʽ¡£
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));
System.out.println(names);
}
}