1. Variability: Strings are String constants that, once created, cannot be changed until destroyed. StringBuffer and StringBuilder objects are mutable character arrays.

The reason: The String class uses the final keyword to decorate character arrays, while the other two inherit AbstractStringBuilder classes that don't use final.Copy the code

2. Thread-safe: Strings are constants and thread-safe. A StringBuffer imposes a synchronized lock on methods, which is also thread-safe. StringBuilder does not place synchronization locks on methods, so it is not thread-safe.

3. Performance: String: Every time a String object is changed, a new String object is created and a pointer is pointed to the new String object. StringBuffer: Each change operates directly on the original StringBuffer object, rather than generating a new object. StringBuilder: Perform the same operation on the original object and only get a 10-15% performance improvement, but at the risk of multithreading insecurity.

Summary: Operating on a small amount of data: String Single thread operating on a large amount of data: StringBuilder Multi-thread operating on a large amount of data: StringBuffer