-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ05021.java
43 lines (35 loc) · 1.11 KB
/
J05021.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
43
import java.util.*;
class SinhVien {
private String msv, ten, lop, email;
public SinhVien(String msv, String ten, String lop, String email) {
this.msv = msv.trim();
this.ten = ten.trim();
this.lop = lop.trim();
this.email = email.trim();
}
public String getMsv() {
return msv;
}
public String toString() {
return this.msv + " " + this.ten + " " + this.lop + " " + this.email;
}
}
public class J05021 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<SinhVien> a = new ArrayList<>();
while (sc.hasNext()) {
SinhVien x = new SinhVien(sc.nextLine(), sc.nextLine(), sc.nextLine(), sc.nextLine());
a.add(x);
}
Collections.sort(a, new Comparator<SinhVien>() {
@Override
public int compare(SinhVien o1, SinhVien o2) {
return o1.getMsv().compareTo(o2.getMsv());
}
});
for (SinhVien x : a) {
System.out.println(x);
}
}
}