What is equalsIgnoreCase() in Java?

The equalsIgnoreCase() is a string method in Java. This function is used to compare this string with an input string.

Note: this is a key-word used above which is a reference to the current object.

The equalsIgnoreCase() returns true if the length and the corresponding characters are equal but it is case-insensitive. Otherwise, it returns false.

svg viewer

Syntax

// syntax
public boolean equalsIgnoreCase( String_2 );

Example one

svg viewer
// importing required library.
import java.lang.*;
public class Main {
public static void main(String[] arguments) {
String string_1 = "EdUcAtIvE";
String string_2 = "Educative";
// storing returned value.
boolean retvalue = string_1.equalsIgnoreCase(string_2);
// prints the return value.
System.out.println("string_2 is equal to string_1 = " + retvalue);
}
}

Example two

svg viewer
// importing required library.
import java.lang.*;
public class Main {
public static void main(String[] arguments) {
String string_1 = "EdUcAtIvE";
String string_2 = "Educative Inc.";
// storing returned value.
boolean retvalue = string_1.equalsIgnoreCase(string_2);
// prints the return value.
System.out.println("string_2 is equal to string_1 = " + retvalue);
}
}

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved