StringBuffer
The String is a constant final and cannot be appended. as a result, a large number of objects are created when a large number of strings are used, in order to avoid excessive creation of objects , stringbuffer,stringbuffer similar to String the string buffer, but can be modified.
When multiple strings are spliced, only one stringbuffer object is produced. Its important method append () returns a reference to its original object, and can append any native type and convert it to a string.
Usage examples:
StringBuffer sb = new StringBuffer ();
sb.append ("Hello"). Append ( "World") . Append (" welcome"). Append (+). Append (False) .
String s = sb.tostring ();
Java.lang.StringBuffer
Public final Class StringBuffer extends Object implements Serializable, Charsequence
A variable sequence of characters for thread safety. A string-like buffer, but can be modified. Although it contains a specific sequence of characters at any point in time, some method calls can change the length and content of the sequence.
String buffers can be safely used with multiple threads. These methods can be synchronized if necessary, so all operations on any particular instance appear to occur in a serial order that is consistent with the sequence of method calls made by each thread involved.
stringbuffer The main operation is &NBSP, APPEND  and &NBSP, INSERT  method, which overloads these methods to accept arbitrary types of data. Each method effectively converts the given data into a string, and then appends or inserts the character of the string into the string buffer. APPEND  The method always adds these characters to the end of the buffer; INSERT 
For example, if z Refer to a current content of "startle" The string buffer is changed to contain the "starlet"
Typically, if sb refers to an instance of StringBuilder, then sb.append (x) and Sb.insert ( Sb.length (), x) has the same effect.
When an operation related to a source sequence, such as an append or insert operation in a source sequence, occurs, the class is synchronized only on the string buffer that performs this operation instead of on the source.
Each string buffer has a certain amount of capacity. As long as the string buffer contains a sequence of characters that does not exceed this capacity, there is no need to allocate a new array of internal buffers. If an internal buffer overflows, this capacity is automatically incremented. Starting with JDK 5 , this class complements the equivalence class used by a single thread, StringBuilder. The StringBuilder class should usually be preferred over this class because it supports all the same operations, but it is faster because it does not perform synchronization.
Java record -29-stringbuffer