Я обнаружил, что реализация метода CompareTo в java.lang.Integer выглядит следующим образом:
public int compareTo(Integer anotherInteger) {
int thisVal = this.value;
int anotherVal = anotherInteger.value;
return ( thisVal < anotherVal ? -1 : ( thisVal == anotherVal ? 0 : 1 ) ) ;
}
Вопрос в том, зачем использовать сравнение вместо вычитания:
return thisVal - anotherVal;
Подробнее здесь: https://stackoverflow.com/questions/272 ... ubtraction