String a = "apple";
String b = "apple";
System.out.println(a.compareTo(b));What is printed?
- A
1
- B
-1
- C
5
- Dcheck_circle
0
Explanation
compareTo returns 0 when both strings are lexicographically equal.
AP Computer Science A· difficulty 3/5
String a = "apple";
String b = "apple";
System.out.println(a.compareTo(b));What is printed?
1
-1
5
0
Explanation
compareTo returns 0 when both strings are lexicographically equal.
Want 10 more like this — adaptive to your weak spots?