public class UsingStringBuffers { public static void main(String [] args) { // Creates a StringBuffer object // with the third // constructor mentioned above. StringBuffer buf = new StringBuffer("Java technologies"); // The append method adds text at the // end of the buffer. // Prints result to screen. buf.append(" are used on desktops and the Internet."); System.out.println(buf); // Prints buf capacity and its actual // length, using // the length and capacity methods. System.out.println("This string is " + buf.length() + " in length."); System.out.println( "But the actual capacity of this buffer is " + buf.capacity()); } }