-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentMain.java
More file actions
39 lines (33 loc) · 1.04 KB
/
Copy pathStudentMain.java
File metadata and controls
39 lines (33 loc) · 1.04 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
import java.util.ArrayList;
import java.util.Collections;
public class StudentMain {
public static void main(String[] args) {
// TODO Auto-generated method stub
Student s1 = new Student("Naoe", 101, 99);
Student s2 = new Student("Shadow", 102, 80);
Student s3 = new Student("Tom", 103, 90);
Student s4 = new Student("Dynamo", 104, 79);
Student s5 = new Student("Danger", 105, 85);
ArrayList<Student> slist = new ArrayList<>();
slist.add(s1);
slist.add(s2);
slist.add(s3);
slist.add(s4);
slist.add(s5);
Collections.sort(slist, Student::CompareName);
System.out.println("Sorted By Names is : ");
System.out.println("--------------------");
for (Student s : slist) {
System.out.println(s);
System.out.println("_______________________");
}
System.out.println();
Collections.sort(slist, Student::CompareRoll);
System.out.println("Sorted By Roll Numbers is : ");
System.out.println("--------------------");
for (Student r : slist) {
System.out.println(r);
System.out.println("_______________________");
}
}
}