LoginSignup
1
0

More than 1 year has passed since last update.

compareToの整理

Last updated at Posted at 2018-04-12

どうしても、compareToが自信がなくなるので、メモ

"1".compareTo("2");// 1 < 2 → -1
"1".compareTo("1");// 1 = 1 → 0
"1".compareTo("0");// 1 > 0 →1

IDEで出てこないものかね?w

こっちのほうが覚えやすいか?

a.compareTo(b) < 0;  // a < b
a.compareTo(b) == 0; // a = b
a.compareTo(b) > 0;  // a > b
1
0
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
1
0