Tutorials Point


  Java Basics
  Java Object Oriented
  Java Advanced
  Java Useful References
  Java Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

Java - String contentEquals() Method


previous next AddThis Social Bookmark Button


Description:

This method returns true if and only if this String represents the same sequence of characters as the specified StringBuffer.

Syntax:

Here is the syntax of this method:

public boolean contentEquals(StringBuffer sb)

Parameters:

Here is the detail of parameters:

  • StringBuffer sb : the StringBuffer to compare to.

Return Value :

  • This method returns true if and only if this String represents the same sequence of characters as the specified StringBuffer, otherwise false.

Example:

public class Test{
   public static void main(String args[]){
      String str1 = "Not immutable";
      String str2 = "Strings are immutable";
      StringBuffer str3 = new StringBuffer( "Not immutable");

      boolean  result = str1.contentEquals( str3 );
      System.out.println(result);
	  
      result = str2.contentEquals( str3 );
      System.out.println(result);
   }
}

This produces following result:

true
false


previous next Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names