String
来源:互联网 发布:mac安装photoshop cc 编辑:程序博客网 时间:2024/05/16 08:22
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 areimmutable(不变的,不可变的) they can be shared(共享). For example:
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 Character
class.
The Java language provides(提供,规定) special(特别的,特殊) support(支持) for the stringconcatenation(串联,连接) operator(操作员,运算符) ( StringBuilder
(orStringBuffer
) class and its append
method. String conversions are implemented through the methodtoString
, defined by Object(是由Oeject定义)
and inherited(继承) by all classes in Java. For additional(附加,额外的,有关) information on string concatenation and conversion, see(查阅)Gosling, Joy, and Steele, The Java Language Specification.
Unless(除非,如果不) otherwise(另外的,其他方面的) noted(说明,注意), passing(经过,传递) a nullargument to a constructor(构造函数) or method in this class will cause a NullPointerException
to be thrown(抛出).
A String
represents a string in the UTF-16 format in which supplementary(补充,增补) charactersare 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 aString
.
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).
- string
- String
- String
- string
- string
- String
- string
- String
- string
- string
- string
- string
- String
- String
- string
- string +
- String
- String
- NUMBER Data Type
- Android_android的测试工具CTS
- poj1080
- C#精髓【月儿原创】第四讲 GridView 72般绝技 .
- 操作系统多级页表计算问题
- String
- StringBuffer
- 找二叉树中两个节点的最近的公共父节点
- 关于linux中的延时函数
- WinForm高级编程之防止多开
- 数字游戏(幸运妈妈)
- https相关
- FORALL
- 寻找素数对 (数论)