Difference between String, StringBuffer and StringBuilder,
1.Comparison of the three methods in execution speed:StringBuilder> StringBuffer> String
2.String <(StringBuffer, StringBuilder)Cause
String: String constant
StringBuffer: string variable
StringBuilder: string variable
3,StringBuilder and StringBuffer
StringBuilder: non-secure thread
StringBuffer: thread-safe
When we are used by multiple threads in the string buffer, 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.
4,Summary of the three usage: 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