Home >>Java String Methods >Java String compareToIgnoreCase() Method

Java String compareToIgnoreCase() Method

Java String compareToIgnoreCase() Method

The compareToIgnoreCase() method in Java String is used to lexicographically compares two strings, ignoring the differences in lower case and upper case.

The comparison depends on the Unicode value of each character in the converted to lower case string

Syntax

public int compareToIgnoreCase(String string2)

Parameter

string2 This parameter is representing A String and the other string to be compared

Technical Details

Returns:It is used to returns An int value: 0 if the string is equal to the other string, ignoring case differences.

Here is an Example of Java String compareToIgnoreCase() Method:

public class MyClass 
{
public static void main(String[] args) 
{
String strln1 = "phptpoint";
String strln2 = "PHPTPOINT";
System.out.println(strln1.compareToIgnoreCase(strln2));
}
}

Output: 0

No Sidebar ads