java.lang.String equalsIgnoreCase()

Description :

This java tutorial shows how to use the equalsIgnoreCase() method of java.lang.String class. This method returns boolean data type which signifies if the String is equal to the parameter String regardless of case. The equalsIgnoreCase() method of String class generally compare two string in terms of their character sequence regardless of case.

Method Syntax :

public boolean equalsIgnoreCase(String anotherString)

Parameter Input :

[table]
Data Type|Parameter|Description
String|anotherString|this is a String parameter where our String is being compared with
[/table]

Method Returns :

This method returns boolean datatype true if one of the following condition has been met regardless of case

  • The two characters are the same (as compared by the == operator)
  • Applying the method Character.toUpperCase(char) to each character of both the Strings resulting to true on each character
  • Applying the method Character.toLowerCase(char) to each character of both the Strings resulting to true on each character

Java Code Example :

This example source code demonstrates the use of equalsIgnoreCase() method of String class. Basically this source code just checks the equality of two strings regardless of character cases.

Sample Output :

Running the equalsIgnoreCase() method example source code of java.lang.String class will give you the following output:

java string equalsignorecase method example

java string equalsignorecase method example

Suggested Reading List :