import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Student implements Comparable<Student>{
String name;
int rollNumber;
Student(String name, int rollNumber) {
this.name = name;
this.rollNumber = rollNumber;
}
public int getRollNumber() {
return rollNumber;
}
public String getName() {
return name;
}
public int compareTo(Student other){
return this.rollNumber-other.rollNumber;
}
}
class Main {
public static void main(String[] args) {
ArrayList<Student> arr=new ArrayList<>();
arr.add(new Student("kusuma",17));
arr.add(new Student("Eishwa",14));
Collections.sort(arr);
for(Student st:arr){
System.out.println(st.getName());
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: