At any point in time it contains some particular sequence of characters, but the length and content of the sequence can be changed through certain method calls. As long as the length of the character sequence contained in the string buffer does not exceed the capacity, it is not necessary to create a new internal buffer array.
String buffers are safe for use by multiple threads.
The methods are synchronized where necessary so that all the operations on any particular instance behave as if they occur in some serial order that is consistent with the order of the method calls made by each of the individual threads involved. For example, suppose k has type int and a has type Object . Overall, this avoids creating many temporary strings. The principal operations on a StringBuffer are the append and insert methods, which are overloaded so as to accept data of any type. Each effectively converts a given datum to a string and then adds the characters of that string to the contents of the string buffer.