+ 5
java string compareTo()Â method compares the given string with current string lexicographically. It returns positive number, negative number or 0.
It compares strings on the basis of Unicode value of each character in the strings.
If first string is lexicographically greater than second string, it returns positive number (difference of character value). If first string is less than second string lexicographically, it returns negative number and if first string is lexicographically equal to second string, it returns 0.
if s1 > s2, it returns positive number Â
if s1 < s2, it returns negative number Â
if s1 == s2, it returns 0 Â