Consider:
String s1 = "ABc";
String s2 = "abc";
System.out.println(s1.compareTo(s2));
On which basis the output will be -32 if only the first character decimal value of s1 and s2 are compared? Is this the correct way?
If String contains more than 1 character, then we should compare each character, but compareTo() method only compares the first character. Isn’t this a bug?
Awitha, suffices for knowing that a negative value must be returned. Which is all that the documentation promises us. Only if the first chars are the same (say,AandA), the method would need to look at the second char of each string.