Saturday 14 June 2014

contentEquals (StringBuffer sb)

public boolean contentEquals(StringBuffer sb)
Compares this string to the specified StringBuffer. The result is true if and only if this String represents the same sequence of characters as the specified StringBuffer.

class StringContentEqualsBuf{
 public static void main(String args[]){
  String s1 = new String("abcd");
  StringBuffer s2 = new StringBuffer("ABCD");
  StringBuffer s3 = new StringBuffer("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