A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/java/java-string-equalsignorecase-method-with-examples/ below:

Java String equalsIgnoreCase() Method - GeeksforGeeks

Java String equalsIgnoreCase() Method

Last Updated : 23 Dec, 2024

In Java, equalsIgnoreCase() method of the String class compares two strings irrespective of the case (lower or upper) of the string. This method returns a boolean value, true if the argument is not null and represents an equivalent String ignoring case, else false.

Input: str1 = "pAwAn";
str2 = "PAWan"
Output: true

Input: str1 = "piwAn";


str2 = "PAWan"
Output: false

Example:

Java
public class Geeks {
  
    public static void main(String[] args) {
      
        String str1 = "GeeKS FOr gEEks";
        String str2 = "geeKs foR gEEKs";
        String str3 = "ksgee orF geeks";

        // Comparing str1 and str2
        boolean res1 = str2.equalsIgnoreCase(str1);

        System.out.println("str2 is equal to str1 = "+ res1);

        // Comparing str2 and str3
        boolean res2 = str2.equalsIgnoreCase(str3);

        System.out.println("str2 is equal to str3 = "+ res2);
    }
}

Output
str2 is equal to str1 = true
str2 is equal to str3 = false
Syntax:

str2.equalsIgnoreCase(str1);

Here str1 is the string that is supposed to be compared.

Return Value: A boolean value that is true if the argument is not null and it represents an equivalent String ignoring case, else false.

Internal Implementation

public boolean equalsIgnoreCase(String str) {
return (this == str) ? true
: (str != null)
&& (str.value.length == value.length)
&& regionMatches(true, 0, str, 0, value.length);
}



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4