Saturday 14 June 2014

contentEquals (CharSequence cs)

public boolean contentEquals(CharSequence cs)
Compares this string to the specified CharSequence. The result is true if and only if this String represents the same sequence of char values as the specified sequence. 

class StringContentEquals{
 public static void main(String args[]){
  String s1 = new String("abcd");
  String s2 = new String("ABCD");
  String s3 = new String("abcd");
  
  System.out.print("Is contents of s1 and s2 are equal ");
  System.out.println(s1.contentEquals(s2));
  System.out.print("Is contents of s1 and s3 are equal ");
  System.out.println(s1.contentEquals(s3));
 }
}

Output
Is contents of s1 and s2 are equal false
Is contents of s1 and s3 are equal true




 
Prevoius                                                 Next                                                 Home

No comments:

Post a Comment