Monday 16 June 2014

equalsIgnoreCase (String anotherString)

public boolean equalsIgnoreCase(String anotherString)
Compares this String to another String, ignoring case considerations. Two strings are considered equal ignoring case if they are of the same length and corresponding characters in the two strings are equal ignoring case.

class StringEqualsIgnoreCase{
 public static void main(String args[]){
  String s1 = new String("Hello");
  String s2 = new String("HELLO");
  
  System.out.print("Is s1 and s2 are equal ");
  System.out.println(s1.equals(s2));
  
  System.out.print("Is s1 and s2 are equal ");
  System.out.println(s1.equalsIgnoreCase(s2));
 }
}

Output
Is s1 and s2 are equal false
Is s1 and s2 are equal true


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment