Как реализовать
class Student implements Comparable<Student> {
private int score;
public int compareTo(Student other) {
return score - other.score; // negative / 0 / positive
}
}
The contract is about the sign, not the number: negative means «I come first», 0 means equal, positive means «the other comes first». Subtracting is the shortest way for numbers. (For very large values the subtraction can overflow; Integer.compare(a, b) is the safe version.)
Notice: your class decides its own natural order. For students by score, for books by year, for cards by rank.