1, String
The value of the string variable cannot be changed, and if the value of the string variable is to be changed, the virtual machine first traverses the string constant in the method area, and if there is a required value, the virtual machine assigns the address of the constant value directly to the string variable, if no such value exists. The virtual machine will additionally divide a block of memory space in the method area to store string constants, and then assign the address to the string variable.
Therefore, the contents of the string class can not be changed after the declaration, the change is only the point of its memory address.
2, StringBuffer
StringBuffer is used to store string objects in a buffer, and the contents of an object can be changed. and is thread-safe.
StringBuffer is not instantiated like a string by direct assignment, he must be instantiated by constructing the method.
3, StringBuilder
StringBuilder is the same as StringBuffer, the contents of the string object can be changed, but the StringBuilder thread is unsafe.
StringBuilder is not instantiated like a string by direct assignment, he must be instantiated by constructing the method.
4. Assign Value
String takes a + connection string or character; StringBuilder or StringBuffer connects characters or strings through the Append method.
5, StringBuffer or StringBuilder common methods
Append, insert, delete, replace, substring, indexOf (find), reverse
String, StringBuffer, StringBuilder differences in Java