LoginSignup
19
18

More than 5 years have passed since last update.

JavaのcompareToが覚えられないからメモ

Posted at

使い方は覚えられても、戻り値が0より小さいとどちらが大きいか思い出せない。

new Integer(1).compareTo(2); // -1
new Integer(1).compareTo(1); // 0
new Integer(1).compareTo(0); // 1
19
18
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
18