Java equalsIgnoreCase() method

    equalsIgnoreCase() method

    This method will allow you to compare the two strings based on the content but ignores the case of the string. This method will return false if the characters of the string do not match else, it will return true.

    Method implementation-

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

    Syntax-

    public boolean equalsIgnoreCase(String anotherString) 

    Example-

    public class Simple{  
    
       public static void main(String[] args)
       {      
    
          String s1="java";  
    
          String s2="java";  
    
          String s3="JAVA";  
    
          System.out.println(s1.equalsIgnoreCase(s2));
    
          System.out.println(s1.equalsIgnoreCase(s3));
    
          System.out.println(s1.equals(s3));
         }
    }  

    Output-

    Java Ignore equal to method