-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSortMain4.java
More file actions
34 lines (25 loc) · 873 Bytes
/
Copy pathSortMain4.java
File metadata and controls
34 lines (25 loc) · 873 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
package collection.compare;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
public class SortMain4 {
public static void main(String[] args) {
MyUser myUser1 = new MyUser("a", 30);
MyUser myUser2 = new MyUser("b", 20);
MyUser myUser3 = new MyUser("c", 10);
List<MyUser> list = new LinkedList<>();
list.add(myUser1);
list.add(myUser2);
list.add(myUser3);
System.out.println("기본 데이터");
System.out.println(list);
System.out.println("Comparable 기본 정렬");
// list.sort(null);
Collections.sort(list);
System.out.println(list);
System.out.println("IdComparator 정렬");
// list.sort(new IdComparator());
Collections.sort(list, new IdComparator());
System.out.println(list);
}
}