Java String equalsIgnoreCase() method example

HQ » Java Tutorial » java.lang » String » equalsIgnoreCase() method example
Java String equalsIgnoreCase() method example 2018-02-19T12:44:12+00:00

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 :

Data Type Parameter Description
String anotherString this is a String parameter where our String is being compared with

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 :

 

Contact Info

Singapore

Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close