Java String equalsIgnoreCase() method


In this program, You will learn how to implement String equalsIgnoreCase() method in Java.


if (a.equalsIgnoreCase(b)) { }


Example: How to implement String equalsIgnoreCase() method in Java

Run it Now
import java.util.Scanner;

class Main {
    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String a, b;

        System.out.print("Enter First String :");
        a = sc.nextLine();
        System.out.print("\nEnter Second String :");
        b = sc.nextLine();

        if (a.equalsIgnoreCase(b)) {
            System.out.print("\nBoth Strings are equal");
        } else {
            System.out.print("\nBoth Strings are not equal");
        }
        
    }
}

Output:

Enter First String :Hello
Enter Second String :hello
Both Strings are equal