public final class String extends Object implements Serializable, Comparable
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 类型是常量,他们被创建后不会背改变,字符串缓冲区支持可变的字符串,因为他们可共享字符串的 对象是不可变的 ,如下面两个是相等的 。 String str = "abc";
is equivalent to:
char data[] = {'a', 'b', 'c'};
String str = new String(data);
Here are some more examples of how strings can be used: 下面有更多的列子 System.out.println("abc"); String cde = "cde"; System.out.println("abc" + cde); String c = "abc".substring(2,3); String d = cde.substring(1, 2);
The class String includes methods for examining individual characters of the sequence, for comparing strings, for searching strings, for extracting substrings, and for creating a copy of a string with all characters translated to uppercase or to lowercase. Case mapping is based on the Unicode Standard version specified by the Character class.
string 类方法包含对单个字符序列的审查,如比较字符串,查找字符串、提取子串和创建字符串的副本将其转换成大写或者小写,映射情况下基于unicode字符串的标准版。
The Java language provides special support for the string concatenation operator ( + ), and for conversion of other objects to strings. String concatenation is implemented through the StringBuilder(or StringBuffer) class and its append method. String conversions are implemented through the method toString, defined by Object and inherited by all classes in Java. For additional information on string concatenation and conversion, see Gosling, Joy, and Steele, The Java Language Specification.
java语言包含专门支持字符串的符号和转换成字符串的方法,字符串的执行通过他的stringbuilder类和它的附加方法。string 包含tostring方法,定义object和继承所有的java类,字符串转换和连接的所有信息参考gosling,joy 和steele中的java语言规范
Unless otherwise noted, passing a null argument to a constructor or method in this class will cause a NullPointerException to be thrown.
除非在特殊的情况下,通过null值访问一个类的构造函数或者方法将会被抛出一个空指针异常。
A String represents a string in the UTF-16 format in which supplementary characters are represented by surrogate pairs (see the section Unicode Character Representations in the Character class for more information). Index values refer to char code units, so a supplementary character uses two positions in a String. 一个字符串代表一个字符串补充格式utf16的字符串,索引值是指编码单元,所以补充字符串在字符串中占用了2个位置。 The String class provides methods for dealing with Unicode code points (i.e., characters), in addition to those for dealing with Unicode code units (i.e., char values).
Since: JDK1.0 See Also: Object.toString(), StringBuffer, StringBuilder, Charset, Serialized Form