Suppose I have below class definition:
public class Student implements Comparable<Student> {
private int id;
private String name;
@Override
public int compareTo(Student o) {
return this.id - o.id;
}
}
Can I use it for TreeSet without implementing hashCode and equals method?