import javax.swing.*;

public class StringBufferCapLen
 {
  public static void main(String args[])
   {
    StringBuffer buffer = 
      new StringBuffer("Hello, how are you?");
    String output = "buffer = " + buffer.toString() +
      "\nlenght = " + buffer.length() +
      "\ncapacity = " + buffer.capacity();
    buffer.ensureCapacity(75);
    output += "\n\nNew capacity = " + buffer.capacity();
    buffer.setLength(10);
    output += "\n\nNew length = " + buffer.length() +
     "\nbuf = " + buffer.toString();
   
    JOptionPane.showMessageDialog(null, output,
    "StringBuffer length and capacity Methods",
     JOptionPane.INFORMATION_MESSAGE);
      
    System.exit(0);
  }
}
    