Difference between StringBuffer and StringBuilder, stringbuilder
1. Comparison of execution speed: StringBuilder> StringBuffer
2. StringBuffer and StringBuilder. They are string variables and changeable objects. Whenever we use them to operate on strings,
It actually operates on an object. Unlike creating some objects like a String, it is faster.
3. StringBuilder: thread-safe
StringBuffer: thread-safe
When we use it in string buffering by multiple threads, the JVM cannot ensure that the StringBuilder operation is safe. Although its speed is the fastest, it can ensure that StringBuffer can be operated correctly. Of course, in most cases, we perform operations in a single thread. In most cases, we recommend using StringBuilder instead of StringBuffer, which is the reason for speed.
Summary: 1. If you want to operate a small amount of data, use = String
2. A single thread operates on a large amount of data in the string buffer = StringBuilder
3. multi-threaded operations on a large amount of data in the string buffer = StringBuffer