String of difference and StringBuffe StringBuilder

1. Variability: String immutable (suitable for making the key HashMap), StringBuffer and StringBuilder variable

2. Performance angles:, String in the new time, will open up in the constant pool space, consuming memory, and StringBuffer, StringBuiilder string buffer (which are all stored in a string), it will be freed

3. Different assignment: StringBuffer StringBuilder and can be established by the constructor, String may also be assigned in addition to the construction methods, such as: String str = "abc";

4. Performance: The string concatenation, String efficient than those two

5. Security: String, StringBuffer security thread, StringBuilder thread-safe, the highest single-threaded StringBuilder efficiency

6. unique features: StringBuffer have to reverse a string function, the other two were not

Guess you like

Origin www.cnblogs.com/chenlong321/p/11767901.html