Stirngbuffer
The contents of the string can be deleted
The composition of a string is implemented by this class.
StringBuffer is a container many methods are the same as String
StringBuffer are variable-length
Characteristics:
Variable length
You can add multiple types
Will eventually become a string through the Tostirng method
StringBuffer function: Add, delete, change, check, of course, there are storage functions.
1. Storage
Append () adds the specified data as a parameter to the end of the existing data.
Insert (index, data) can insert data into the specified index position.
2. Delete
StringBuffer delet (start,end): Deletes the data in the buffer, containing start does not contain end.
StringBuffer Deletcharat (index): Delete the character at the specified position
3. Get
Char charAt (Index):
int indexOf (String str):
int lastIndexOf (String str):
int Length ():
String substring (int start,int end)
4. Modifications
StringBuffer replace (int start,int end,string str)
StringBuilder appeared after the JDK1.5 version.
StringBuffer is thread-synchronized
StringBuilder is thread not synchronizing
StringBuilder A variable sequence of characters. This class is used as a simple replacement for stringbuffer.
In most implementations, it is faster than StringBuffer.
It is not safe to use an instance of StringBuilder for multiple threads, and StringBuffer is recommended if such synchronization is required.
Java------stringbuffer