---restore content starts---
- string literal constant
- StringBuffer string variable (thread safe)
- StringBuilder string variable (non-thread safe)
String is a constant, and the value of the object has been assigned and cannot be changed. If you do not want to change, you can re-create another object, and then assign the value to the newly created object.
StringBuffer is a variable and is a quantity that can change at any time. If the StringBuffer object is changed, each result will be manipulated against the StringBuffer object instead of generating a new object. Therefore, it is recommended to use StringBuffer if the general string changes frequently.
StringBuilder and StringBuffer class functions are basically similar, the method is the same, the main difference is that StringBuffer class method is multithreaded security, and StringBuilder is not thread-safe, The StringBuilder class would be slightly faster than that.
---restore content ends---
The difference between string, StringBuilder, and StringBuffer in Java