String, StringBuffer and StringBuilder difference

1 Overview

  String is a string constant, StringBuffer is thread-safe string variable, but StringBuilder is not thread-safe string variable

2, String and StringBuffer difference

  The main difference is that constant string String type is immutable, and StringBuffer string variable is a variable type. Every variable of type String modifications, will create a new String object, and the pointer to the new String object. The type of StringBuffer modify variables, does not create a new string object, but directly modify the contents of the original string object.

3, StringBuffer and StringBuilder difference

  StringBuffer is thread-safe, mutable sequence of characters, StringBuilder non-thread-safe, without further notice.

Guess you like

Origin www.cnblogs.com/xwwbb/p/11306413.html