String toString () : This method returns the value of the invoking StringBuffer object that invoked the method as a string. For example: The statement,
String s = s1.toString();
The String object s will contain “Hello Java”.
public class StringBuffertoString
{
public static void main(String[] args)
{
StringBuffer sl = new StringBuffer("Hello Java");
System.out.println("sl.toString() : " + sl.toString());
}
}