String.compareToIgnoreCase()

Signature

int compareToIgnoreCase (String s1, String s2)

Domain

action, condition

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

NameTypeDescription
s1StringA String to compare.
s2StringA second String to compare.

Returns

TypeDescription
intA negative integer, zero, or a positive integer as s1 is greater than, equal to, or less than s2 ignoring case considerations.

Cautions

none

Example


int result = String.compareToIgnoreCase ("This IS a test", "This is a tesq");

Result is:
result contains: -1