Class java.lang.StringBuffer


  • Objects of String have a fixed length. Nothing can be appended or inserted. Therfore StringBuffer class is used.
    public static String list_items (int[] items)
    {
    	StringBuffer result = new StringBuffer();
    
    	for (int i=0; i<items.length; i++)
    		result.append(items[i]+", ");
    
    	return result.toString();
    }
    	
  • Internal storage managment: Each StringBuffer object has a certain capacity. If the length exceeds the capacity it will be rearranged in storage including extra free space automatically.

Java Tutorial - Standard Classes Jens Trapp, 1997