-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
48 lines (41 loc) · 890 Bytes
/
Test.java
File metadata and controls
48 lines (41 loc) · 890 Bytes
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
43
44
45
46
47
48
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class Test {
private String dd;
@org.junit.Test
public void getNav(){
List<Test> list = new ArrayList<Test>();
Test t = new Test();
t.setDd("aaa");
list.add(t);
t = new Test();
t.setDd("asdfase");
list.add(t);
t = new Test();
t.setDd("a344taa");
list.add(t);
t = new Test();
t.setDd("3raf");
list.add(t);
for (Test test : list) {
System.out.println(test.getDd());
}
Collections.sort(list, new Comparator<Test>() {
public int compare(Test o1, Test o2) {
return o1.getDd().compareTo(o2.getDd());
}
});
System.out.println("===================");
for (Test test : list) {
System.out.println(test.getDd());
}
}
public String getDd() {
return dd;
}
public void setDd(String dd) {
this.dd = dd;
}
}