public class Test {
public static void main(String[] args) {
Set<Student> set = new TreeSet<Student>();
set.add(new Student("1",21));
set.add(new Student("2",22));
System.out.println(set);
}
}
class Student implements Comparable<Student> {
private String name;
private int age;
Student(String name,int age) {
this.name = name;
this.age = age;
}
public Student(String string) {
// TODO Auto-generated constructor stub
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
@Override
public String toString() {
return "Student [name=" + name + ", age=" + age + "]";
}