String.compareToIgnoreCase()
Signature
int compareToIgnoreCase (String s1, String s2)
Description
Compares two strings lexicographically, ignoring case differences.
This method returns an integer whose sign is that of calling compareTo
with normalized versions of the strings where case differences have been
eliminated by lowercasing each character.
Note that this method does not take locale into account, and will result
in an unsatisfactory ordering for certain locales.
Parameters
Name | Type | Description |
s1 | String | A String to compare. |
s2 | String | A second String to compare. |
Returns
Type | Description |
int | A negative integer, zero, or a positive integer as s1 is
greater than, equal to, or less than s2 ignoring case considerations. |
Example
int result = String.compareToIgnoreCase ("This IS a test", "This is a tesq");
Result is:
result contains: -1