Java中String, StringBuffer, StringBuilder

String:

  1, it is a string constant, it can not be modified once created. Modifications have been around for a String object is to re-create a new object, and then save the new value into it.

  2, String class is final and can not be inherited.

  3, and the String object rather than a basic type.

  4, string equals method and override hashCode () methods.

StingBuffer:

  1, the object is a variable character string, the string can be operated, a new object does not modify the original string value.

  2, the efficiency is slow, but the thread safety

  3, StringBuffer not override equals and hashCode () method.

  4, character data may be dynamically configured, the append () method.

StringBuilder:

  1, the object is a string variable, the StringBuffer like, can operate on the string, it will not create a new object.

  2, the efficiency and efficient, but not thread-safe.

Guess you like

Origin www.cnblogs.com/noperx/p/11359681.html