The java String, StringBuffer and StringBuilder

String class is immutable classes, i.e., once after a String object is created, comprising a sequence of characters in the object is not changed until the object is destroyed.


 

StringBuffer object a variable character string is a sequence represented When a StringBuffer is created by providing a StringBuffer append (), insert (), reverse (), setCharAt (), setLength () method and the like may change the string character sequence objects. Once the desired final string generated by the StringBuffer, you can call its toString () method to convert it to a String object.

StringBuffer object variable is a string of characters, it does not regenerate an object, the original object and can be connected in a new string.

StringBuffer is thread-safe


 

StringBuilder class variable also represents a String object. Thread does not implement security features, so performance is slightly higher than StringBuffer

 


For details, see: https: //blog.csdn.net/csxypr/article/details/92378336

 

 

Guess you like

Origin www.cnblogs.com/DirWang/p/11907841.html