Compare two strings while disregarding differences in case:
String |
The compareToIgnoreCase() method compares two strings based on their order in the dictionary, disregarding differences in case.
The comparison relies on the Unicode value of each character within the string, which is converted to lowercase before comparison.
The method returns 0 when the strings are equal, disregarding case differences. If the string is less than the other string (fewer characters), it returns a value less than 0; if the string is greater than the other string (more characters), it returns a value greater than 0.
public |
Parameter |
Description |
string2 |
A string that represents the comparison target. |
Returns |
An integer value: 0 signifies equality between the strings, disregarding case differences. If the string is lexicographically before the other string, it returns a value less than 0. If the string is lexicographically after the other string (contains more characters), it returns a value greater than 0. |
Java version |
1.2 |