回答編集履歴
1
引き算だと最小値と0との関係が・・・
answer
CHANGED
@@ -13,7 +13,8 @@
|
|
13
13
|
return this.getNum() - another.getNum();
|
14
14
|
}
|
15
15
|
```
|
16
|
+
でも十分です(ただし0とInteger.MIN_VALUEとの比較でこれを使うと不整合を起こすので注意)。
|
16
|
-
|
17
|
+
あるいは、Integerクラスに2つのint値を比較するstaticメソッドも存在するので、
|
17
18
|
```java
|
18
19
|
public int compateTo(Car another){
|
19
20
|
return Integer.compare(this.getNum(), another.getNum());
|