No. Upper and lower case matter in string comparisons.
Upper case characters are regarded as less than lower case characters.
So "APPLE".compareTo("apple")
returns a negative integer.
When strings are compared, case-sensitive dictionary order is used. Mostly this means that when two strings of the same case are compared, the one that appears first in the dictionary is less than the other. The technical term for this is lexicographic order. Here are the details:
Rule 1: If
A.compareTo(B) == 0
, thenA
andB
are the same length (counting all characters, including blanks and punctuation) and each character inA
is identical (including case) to the character inB
at the same location.
"batcave".compareTo("batcave") == 0 "batcave".compareTo("bat cave") != 0
There are more rules on the following pages ...
Decide which strings, when used with compareTo()
return zero.