java.lang.Integer
メソッドの実装はcompareTo
次のようになります。
public int compareTo(Integer anotherInteger) {
int thisVal = this.value;
int anotherVal = anotherInteger.value;
return (thisVal<anotherVal ? -1 : (thisVal==anotherVal ? 0 : 1));
}
問題は、減算ではなく比較を使用する理由です。
return thisVal - anotherVal;