String compareTo Method Output
What is printed to the console when the following code segment is executed?
String s1 = "avocado";
String s2 = "banana";
System.out.println(s1.compareTo(s2) + " " + s2.compareTo(s1));
A
0 0
B
1 -1
C
-1 -1
D
-1 1
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | lsj08030922 | 1 | 2 | 1m 26s | 4 |
| #2 | ngvandangthanh | 0 | 1 | 0m 00s | -10 |
| #3 | patrickmeijer009 | 1 | 4 | 1m 35s | -25 |
| #4 | jeonsaw1723 | 0 | 1 | 0m 37s | -47 |
| #5 | thamminenigamya | 1 | 1 | 3m 45s | -125 |
Items per page:
10
1 – 5 of 5
APFIVE