* The String class is an immutable class. As long as String is modified, a new object will be generated.
* StringBuffer and StringBuilder are both mutable classes, and any changes to the string will not create new objects.
In actual use, if you often need to modify a string, such as inserting, deleting, etc.
* But what is the difference between StringBuffer and StringBuilder?
StringBuffer is thread-safe and is very convenient to use in multi-threaded programs, but the efficiency of the program will be slower.
StringBuilder is not thread-safe and is more efficient than StringBuffer in a single thread.
* In summary, the running time of the three:
String > StringBuffer > StringBuilder
The above article briefly talks about String in Java. The difference between StringBuffer and StringBuilder is small. I have compiled all the content shared with you. I hope it can give you a reference. I also hope that everyone will support the PHP Chinese website.
For more articles on the differences between String StringBuffer and StringBuilder in Java, please pay attention to the PHP Chinese website!