filmov
tv
Java String compareTo() method

Показать описание
compareTo() is used for comparing two strings lexicographically.
Each character of both the strings is converted into a Unicode value for comparison. If both the strings are equal then this method returns 0.
It returns a positive value if the first string is lexicographically greater than the second string else a negative value.
compareTo() method is case sensitive. However, we do have a case insensitive compare method in string class
The compareToIgnoreCase() ignores the case while comparing two strings.
Each character of both the strings is converted into a Unicode value for comparison. If both the strings are equal then this method returns 0.
It returns a positive value if the first string is lexicographically greater than the second string else a negative value.
compareTo() method is case sensitive. However, we do have a case insensitive compare method in string class
The compareToIgnoreCase() ignores the case while comparing two strings.