public final class String
extends Object
implements Serializable, Comparable<String>, CharSequence
The String class represents character strings. All string literals in Java programs, such as "abc", are implemented as instances of this class.
Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared. For example:
String str = "abc";
is equivalent to:
char data[] = {'a', 'b', 'c'};
String str = new String(data);
<div class="quote"><blockquote>Class StringBuffer
java.lang.Object
java.lang.StringBuffer
All Implemented Interfaces:
Serializable, Appendable, CharSequence
public final class StringBuffer
extends Object
implements Serializable, CharSequence
A thread-safe, mutable sequence of characters. A string buffer is like a String, but can be modified. At any point in time it contains some particular sequence of characters, but the length and content of the sequence can be changed through certain method calls.
String buffers are safe for use by multiple threads. The methods are synchronized where necessary so that all the operations on any particular instance behave as if they occur in some serial order that is consistent with the order of the method calls made by each of the individual threads involved.
java.lang
Class StringBuilder
java.lang.Object
java.lang.StringBuilder
All Implemented Interfaces:
Serializable, Appendable, CharSequence
public final class StringBuilder
extends Object
implements Serializable, CharSequence
A mutable sequence of characters. This class provides an API compatible with StringBuffer, but with no guarantee of synchronization. This class is designed for use as a drop-in replacement for StringBuffer in places where the string buffer was being used by a single thread (as is generally the case). Where possible, it is recommended that this class be used in preference to StringBuffer as it will be faster under most implementations.
唐洪超 发表于 2015-12-12 20:46
String可以储存和操作字符串,即包含多个字符的字符数据。这个String类提供了存储数值不可改变的字符串。 ...
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |