Java String equalsIgnoreCase() Method

Java String equalsIgnoreCase() method compares two string ignoring case considerations.

Two Strings are said to be equal ignoring case if they are of the same length and each character matches with the respective character of the other string ignoring case.

String str = “abc”;
String str1 = “ABc”;

str and str1 when compared using equalsIgnoreCase() method, would return true as case is ignored in this case.

Signature of equalsIgnoreCase() Method:

boolean java.lang.String.equalsIgnoreCase(String anotherString)

Example : Java String equalsIgnoreCase() method

The below program explains String equalsIgnoreCase() method.

package com.masterjavatutorial;

public class Test {
	public static void main(String[] args) {
		String str ="HelloWorld";
		String str1 = "helloworld";
		boolean equal = str.equalsIgnoreCase(str1);

Output of the above program is as below: