String a = "apple";
String b = "banana";
System.out.println(a.compareTo(b) < 0);What is printed?
- A
0
- B
-1
- C
false
- Dcheck_circle
true
Explanation
"apple" comes before "banana" lexicographically, so compareTo returns a negative integer, which is less than 0.