-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReWriteCompare.java
More file actions
50 lines (41 loc) · 1.1 KB
/
ReWriteCompare.java
File metadata and controls
50 lines (41 loc) · 1.1 KB
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
49
50
package algorithmtest;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.*;
public class ReWriteCompare {
static class Student {
public int s_no;
public String s_name;
public int s_class;
public void t()
{
}
public Student(int no) {
this.s_no = no;
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
TreeSet <Student>s = new TreeSet<Student>(new Comparator<Student>() {
@Override
public int compare(Student o1, Student o2) {
// TODO Auto-generated method stub
return o1.s_no-o2.s_no;
}});
s.add(new Student(3));
s.add(new Student(6));
s.add(new Student(2));
List<Student>c = new ArrayList<Student>();
Collections.sort(c, ( a, b)->{return a.s_no-b.s_no;});
Map<Student,Integer> m = new HashMap<Student,Integer>();
//Map tm = new TreeMap<Student,Integer>(m,);
// Collections.sort( s,new Comparator<Student>() { //illegal
//
// @Override
// public int compare(Student o1, Student o2) {
// // TODO Auto-generated method stub
// return o1.s_no-o2.s_no;
// }});
}
}