// Program to explain the following StringBuffer function :
// void setLength( int len )class MsetLength
{
public static void main(String args[ ])
{
StringBuffer sb1 = new StringBuffer("Java Programming Examples.");
System.out.println(" String = " + sb1);sb1.setLength(12);
System.out.println(" String = " + sb1);
sb1.setLength(4);
System.out.println(" String = " + sb1);
}
}
Output:String = Java Programming Examples.
String = Java Program
String = Java