Java-IgnoreCase

IgnoreCase

A minor variant of the equals( ) method, namely the equalsIgnoreCase( ) method is also available. This method ignores the case of each character in the strings during the comparison. For example, in the following program, the case of each character is ignored by the equalsIgnoreCase( ) method, this method will return the value true.

Program

1

Program Source

public class Javaapp {
    
    public static void main(String[] args){
        
        String str1 = new String("hajsof");
        String str2 = new String("HAJSOF");
        
        if(str1.equals(str2))
        {
            System.out.println("equals() : Both values are same");
        }
        if(str1.equalsIgnoreCase(str2))
        {
            System.out.println("equalsIgnoreCase() : Both values are same");
        }
   }
}

Leave a Comment