Java string storage and operation class. I have used string, stringbuffer, stringbuilder.
The class definition of string is public final class string, that is, it cannot be inherited. in addition, the string object storage value is unchangeable. if a String object stores the value of "ABC", you cannot change ABC to ABCD. unless you change the reference of the string variable to point it to another string object.
Stringbuffer and stringbuilder can store strings or change the values of stored objects.
The difference is that stringbuffer is thread-safe. Using this in multithreading will not result in different results every time it is run, but it also sacrifices the performance.
Stringbuilder is NOT thread-safe and is suitable for single-threaded scenarios. However, it is better in performance than stringbuffer.
When a single thread needs to modify the value of the stored string, stringbuilder is preferred.