String java中文

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 类包括的方法可用于检查序列的单个字符、比较字符串、搜索字符串、提取子字符串、创建字符串副本并将所有字符全部转换为大写或小写。大小写映射基于
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
17 类指定的 Unicode 标准版。

Java 语言提供对字符串串联符号("+")以及将其他对象转换为字符串的特殊支持。字符串串联是通过

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
18(或
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
19)类及其
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
20 方法实现的。字符串转换是通过
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
21 方法实现的,该方法由
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
22 类定义,并可被 Java 中的所有类继承。有关字符串串联和转换的更多信息,请参阅 Gosling、Joy 和 Steele 合著的 The Java Language Specification。

除非另行说明,否则将 null 参数传递给此类中的构造方法或方法将抛出

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
23。

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 表示一个 UTF-16 格式的字符串,其中的增补字符 由代理项对 表示(有关详细信息,请参阅
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
17 类中的 Unicode 字符表示形式)。索引值是指
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 代码单元,因此增补字符在
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 中占用两个位置。

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 类提供处理 Unicode 代码点(即字符)和 Unicode 代码单元(即
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值)的方法。

从以下版本开始:JDK1.0另请参见:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
30,
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
19,
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
18,
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
33, 序列化表格
 构造方法摘要
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
34
          初始化一个新创建的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象,使其表示一个空字符序列。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
36
          通过使用平台的默认字符集解码指定的 byte 数组,构造一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
38
          通过使用指定的 charset 解码指定的 byte 数组,构造一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
40
          已过时。 该方法无法将字节正确地转换为字符。从 JDK 1.1 开始,完成该转换的首选方法是使用带有
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
33、字符集名称,或使用平台默认字符集的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 构造方法。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
43
          通过使用平台的默认字符集解码指定的 byte 子数组,构造一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
45
          通过使用指定的 charset 解码指定的 byte 子数组,构造一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
47
          已过时。 该方法无法将字节正确地转换为字符。从 JDK 1.1 开始,完成该转换的首选方法是使用带有
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
33、字符集名称,或使用平台默认字符集的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 构造方法。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
50
          通过使用指定的字符集解码指定的 byte 子数组,构造一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
52
          通过使用指定的 charset 解码指定的 byte 数组,构造一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
54
          分配一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14,使其表示字符数组参数中当前包含的字符序列。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
56
          分配一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14,它包含取自字符数组参数一个子数组的字符。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
58
          分配一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14,它包含 Unicode 代码点数组参数一个子数组的字符。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
60
          初始化一个新创建的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象,使其表示一个与参数相同的字符序列;换句话说,新创建的字符串是该参数字符串的副本。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
62
          分配一个新的字符串,它包含字符串缓冲区参数中当前包含的字符序列。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
63
          分配一个新的字符串,它包含字符串生成器参数中当前包含的字符序列。     

CASE_INSENSITIVE_ORDER

public static final Comparator<String> CASE_INSENSITIVE_ORDER
一个对
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象进行排序的 Comparator,作用与
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
65 相同。此比较器是可序列化的。

注意,Comparator 不 考虑语言环境,因此可能导致在某些语言环境中的排序效果不理想。java.text 包提供 Collator 完成与语言环境有关的排序。

从以下版本开始:1.2另请参见:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
66
public String()
初始化一个新创建的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象,使其表示一个空字符序列。注意,由于 String 是不可变的,所以无需使用此构造方法。
public String(String original)
初始化一个新创建的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象,使其表示一个与参数相同的字符序列;换句话说,新创建的字符串是该参数字符串的副本。由于 String 是不可变的,所以无需使用此构造方法,除非需要
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
69 的显式副本。参数:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
69 - 一个
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。
public String(char[] value)
分配一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14,使其表示字符数组参数中当前包含的字符序列。该字符数组的内容已被复制;后续对字符数组的修改不会影响新创建的字符串。参数:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
73 - 字符串的初始值
public String(char[] value,
              int offset,
              int count)
分配一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14,它包含取自字符数组参数一个子数组的字符。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 参数是子数组第一个字符的索引,
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
76 参数指定子数组的长度。该子数组的内容已被复制;后续对字符数组的修改不会影响新创建的字符串。参数:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
73 - 作为字符源的数组。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 - 初始偏移量。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
76 - 长度。抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 和
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
76 参数索引字符超出
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
73 数组的范围。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
0分配一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14,它包含 Unicode 代码点数组参数一个子数组的字符。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 参数是该子数组第一个代码点的索引,
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
76 参数指定子数组的长度。将该子数组的内容转换为
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26;后续对
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
88 数组的修改不会影响新创建的字符串。参数:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
89 - 作为 Unicode 代码点的源的数组。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 - 初始偏移量。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
76 - 长度。抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
92 - 如果在
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
89 中发现任何无效的 Unicode 代码点
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 和
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
76 参数索引字符超出
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
89 数组的范围。从以下版本开始:1.5
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
1已过时。 该方法无法将字节正确地转换为字符。从 JDK 1.1 开始,完成该转换的首选方法是使用带有
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
33、字符集名称,或使用平台默认字符集的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 构造方法。分配一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14,它是根据一个 8 位整数值数组的子数组构造的。

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 参数是该子数组的第一个 byte 的索引,
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
76 参数指定子数组的长度。

子数组中的每个

     String str = "abc";
 
03 都按照上述方法转换为
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26。

参数:
     String str = "abc";
 
05 - 要转换为字符的 byte。
     String str = "abc";
 
06 - 每个 16 位 Unicode 代码单元的前 8 位。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 - 初始偏移量。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
76 - 长度。抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 或
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
76 参数无效。另请参见:
     String str = "abc";
 
12,
     String str = "abc";
 
13,
     String str = "abc";
 
14,
     String str = "abc";
 
15,
     String str = "abc";
 
16,
     String str = "abc";
 
17,
     String str = "abc";
 
18
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
2已过时。 该方法无法将字节正确地转换为字符。从 JDK 1.1 开始,完成该转换的首选方法是使用带有
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
33、字符集名称,或使用平台默认字符集的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 构造方法。分配一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14,它包含根据一个 8 位整数值数组构造的字符。所得字符串中的每个字符 c 都是根据 byte 数组中的相应组件 b 构造的,如下所示:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
3
参数:
     String str = "abc";
 
05 - 要转换为字符的 byte。
     String str = "abc";
 
06 - 每个 16 位 Unicode 代码单元的前 8 位。另请参见:
     String str = "abc";
 
13,
     String str = "abc";
 
14,
     String str = "abc";
 
15,
     String str = "abc";
 
16,
     String str = "abc";
 
17,
     String str = "abc";
 
18
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
4通过使用指定的字符集解码指定的 byte 子数组,构造一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。新
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 的长度是一个字符集函数,因此可能不等于子数组的长度。

当给定 byte 在给定字符集中无效的情况下,此构造方法的行为没有指定。如果需要对解码过程进行更多控制,则应该使用

     String str = "abc";
 
32 类。

参数:
     String str = "abc";
 
33 - 要解码为字符的 byte
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 - 要解码的第一个 byte 的索引
     String str = "abc";
 
35 - 要解码的 byte 数
     String str = "abc";
 
36 - 受支持 charset 的名称抛出:
     String str = "abc";
 
37 - 如果指定的字符集不受支持
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 和
     String str = "abc";
 
35 参数索引字符超出
     String str = "abc";
 
33 数组的范围从以下版本开始:JDK1.1
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
5通过使用指定的 charset 解码指定的 byte 子数组,构造一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。新
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 的长度是字符集的函数,因此可能不等于子数组的长度。

此方法总是使用此字符集的默认替代字符串替代错误输入 (malformed-input) 和不可映射字符 (unmappable-character) 序列。如果需要对解码过程进行更多控制,则应该使用

     String str = "abc";
 
32 类。

参数:
     String str = "abc";
 
33 - 要解码为字符的 byte
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 - 要解码的第一个 byte 的索引
     String str = "abc";
 
35 - 要解码的 byte 数
     String str = "abc";
 
48 - 用来解码
     String str = "abc";
 
33 的 charset抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 和
     String str = "abc";
 
35 参数索引字符超出
     String str = "abc";
 
33 数组的边界从以下版本开始:1.6
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
6通过使用指定的 charset 解码指定的 byte 数组,构造一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。新
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 的长度是字符集的函数,因此可能不等于 byte 数组的长度。

当给定 byte 在给定字符集中无效的情况下,此构造方法的行为没有指定。如果需要对解码过程进行更多控制,则应该使用

     String str = "abc";
 
32 类。

参数:
     String str = "abc";
 
33 - 要解码为字符的 byte
     String str = "abc";
 
36 - 受支持的 charset 的名称抛出:
     String str = "abc";
 
37 - 如果指定字符集不受支持从以下版本开始:JDK1.1
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
7通过使用指定的 charset 解码指定的 byte 数组,构造一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。新
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 的长度是字符集的函数,因此可能不等于 byte 数组的长度。

此方法总是使用此字符集的默认替代字符串替代错误输入和不可映射字符序列。如果需要对解码过程进行更多控制,则应该使用

     String str = "abc";
 
32 类。

参数:
     String str = "abc";
 
33 - 要解码为字符的 byte
     String str = "abc";
 
48 - 要用来解码
     String str = "abc";
 
33 的 charset从以下版本开始:1.6
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
8通过使用平台的默认字符集解码指定的 byte 子数组,构造一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。新
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 的长度是字符集的函数,因此可能不等于该子数组的长度。

当给定 byte 在给定字符集中无效的情况下,此构造方法的行为没有指定。如果需要对解码过程进行更多控制,则应该使用

     String str = "abc";
 
32 类。

参数:
     String str = "abc";
 
33 - 要解码为字符的 byte
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 - 要解码的第一个 byte 的索引
     String str = "abc";
 
35 - 要解码的 byte 数抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 和
     String str = "abc";
 
35 参数索引字符超出
     String str = "abc";
 
33 数组的范围从以下版本开始:JDK1.1
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
9通过使用平台的默认字符集解码指定的 byte 数组,构造一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。新
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 的长度是字符集的函数,因此可能不等于 byte 数组的长度。

当给定 byte 在给定字符集中无效的情况下,此构造方法的行为没有指定。如果需要对解码过程进行更多控制,则应该使用

     String str = "abc";
 
32 类。

参数:
     String str = "abc";
 
33 - 要解码为字符的 byte从以下版本开始:JDK1.1
     String str = "abc";
 
0分配一个新的字符串,它包含字符串缓冲区参数中当前包含的字符序列。该字符串缓冲区的内容已被复制,后续对它的修改不会影响新创建的字符串。参数:
     String str = "abc";
 
80 - 一个
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
19
     String str = "abc";
 
1分配一个新的字符串,它包含字符串生成器参数中当前包含的字符序列。该字符串生成器的内容已被复制,后续对它的修改不会影响新创建的字符串。

提供此构造方法是为了简化到

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
18 的迁移。通过
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
21 方法从字符串生成器中获取字符串可能运行的更快,因此通常作为首选。

参数:
     String str = "abc";
 
84 - 一个
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
18从以下版本开始:1.5

length

     String str = "abc";
 
2返回此字符串的长度。长度等于字符串中 Unicode 代码单元的数量。指定者:接口
     String str = "abc";
 
86 中的
     String str = "abc";
 
87返回:此对象表示的字符序列的长度。

isEmpty

     String str = "abc";
 
3当且仅当
     String str = "abc";
 
88 为 0 时返回 true。返回:如果
     String str = "abc";
 
88 为 0,则返回 true;否则返回 false。从以下版本开始:1.6

charAt

     String str = "abc";
 
4返回指定索引处的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值。索引范围为从
     String str = "abc";
 
91 到
     String str = "abc";
 
92。序列的第一个
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值位于索引
     String str = "abc";
 
91 处,第二个位于索引
     String str = "abc";
 
95 处,依此类推,这类似于数组索引。

如果索引指定的

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值是代理项,则返回代理项值。

指定者:接口
     String str = "abc";
 
86 中的
     String str = "abc";
 
98参数:
     String str = "abc";
 
99 -
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值的索引。返回:此字符串指定索引处的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值。第一个
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值位于索引
     String str = "abc";
 
91 处。抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果
     String str = "abc";
 
99 参数为负或小于此字符串的长度。

codePointAt

     String str = "abc";
 
5返回指定索引处的字符(Unicode 代码点)。索引引用
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值(Unicode 代码单元),其范围从
     String str = "abc";
 
91 到
     String str = "abc";
 
88
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
09。

如果给定索引指定的

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值属于高代理项范围,则后续索引小于此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 的长度;如果后续索引处的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值属于低代理项范围,则返回该代理项对相应的增补代码点。否则,返回给定索引处的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值。

参数:
     String str = "abc";
 
99 -
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值的索引返回:
     String str = "abc";
 
99 处字符的代码点值抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果
     String str = "abc";
 
99 参数为负或小于此字符串的长度。从以下版本开始:1.5

codePointBefore

     String str = "abc";
 
6返回指定索引之前的字符(Unicode 代码点)。索引引用
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值(Unicode 代码单元),其范围从
     String str = "abc";
 
95 到
     String str = "abc";
 
35。

如果

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
22 处的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值属于低代理项范围,则
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
24 为非负;如果
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
24 处的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值属于高低理项范围,则返回该代理项对的增补代码点值。如果
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
27 处的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值是未配对的低(高)代理项,则返回代理项值。

参数:
     String str = "abc";
 
99 - 应返回的代码点之后的索引返回:给定索引前面的 Unicode 代码点。抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果
     String str = "abc";
 
99 参数小于 1 或大于此字符串的长度。从以下版本开始:1.5

codePointCount

     String str = "abc";
 
7返回此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 的指定文本范围中的 Unicode 代码点数。文本范围始于指定的
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
33,一直到索引
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
34 处的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26。因此,该文本范围的长度(用
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 表示)是
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
37。该文本范围内每个未配对的代理项计为一个代码点。参数:
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
33 - 文本范围的第一个
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 的索引。
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
40 - 文本范围的最后一个
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 之后的索引。返回:指定文本范围中 Unicode 代码点的数量抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
33 为负,或
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
40 大于此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 的长度,或
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
33 大于
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
40。从以下版本开始:1.5

offsetByCodePoints

     String str = "abc";
 
8返回此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 中从给定的
     String str = "abc";
 
99 处偏移
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
50 个代码点的索引。文本范围内由
     String str = "abc";
 
99 和
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
50 给定的未配对代理项各计为一个代码点。参数:
     String str = "abc";
 
99 - 要偏移的索引
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
50 - 代码点中的偏移量返回:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 的索引抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果
     String str = "abc";
 
99 为负或大于此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 的长度;或者
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
50 为正,且以
     String str = "abc";
 
99 开头子字符串的代码点比
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
50 少;如果
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
50 为负,且
     String str = "abc";
 
99 前面子字符串的代码点比
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
50 的绝对值少。从以下版本开始:1.5

getChars

     String str = "abc";
 
9将字符从此字符串复制到目标字符数组。

要复制的第一个字符位于索引

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
65 处;要复制的最后一个字符位于索引
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
66 处(因此要复制的字符总数是
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
67)。要复制到
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
68 子数组的字符从索引
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
69 处开始,并结束于索引:

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
0
参数:
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
65 - 字符串中要复制的第一个字符的索引。
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
71 - 字符串中要复制的最后一个字符之后的索引。
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
68 - 目标数组。
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
69 - 目标数组中的起始偏移量。抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果下列任何一项为 true:
  •      char data[] = {'a', 'b', 'c'};
         String str = new String(data);
     
    65 为负。
  •      char data[] = {'a', 'b', 'c'};
         String str = new String(data);
     
    65 大于
         char data[] = {'a', 'b', 'c'};
         String str = new String(data);
     
    71
  •      char data[] = {'a', 'b', 'c'};
         String str = new String(data);
     
    71 大于此字符串的长度
  •      char data[] = {'a', 'b', 'c'};
         String str = new String(data);
     
    69 为负
  •      char data[] = {'a', 'b', 'c'};
         String str = new String(data);
     
    80 大于
         char data[] = {'a', 'b', 'c'};
         String str = new String(data);
     
    81

getBytes

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
1已过时。 该方法无法将字符正确转换为字节。从 JDK 1.1 起,完成该转换的首选方法是通过
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
82 方法,该方法使用平台的默认字符集。将字符从此字符串复制到目标 byte 数组中。每个 byte 接收相应字符的 8 个低位。不复制每个字符的高位,它们不参与任何方式的转换。

要复制的第一个字符位于索引

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
65 处;要复制的最后一个字符位于索引
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
66 处。要复制的字符总数为
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
67。将转换为 byte 的字符复制到
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
68 的子数组中,从索引
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
69 处开始,并结束于索引:

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
0
参数:
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
65 - 字符串中要复制的第一个字符的索引
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
71 - 字符串中要复制的最后一个字符之后的索引
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
68 - 目标数组
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
69 - 目标数组中的起始偏移量抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果下列任何一项为 true:
  •      char data[] = {'a', 'b', 'c'};
         String str = new String(data);
     
    65 为负
  •      char data[] = {'a', 'b', 'c'};
         String str = new String(data);
     
    65 大于
         char data[] = {'a', 'b', 'c'};
         String str = new String(data);
     
    71
  •      char data[] = {'a', 'b', 'c'};
         String str = new String(data);
     
    71 大于此 String 的长度
  •      char data[] = {'a', 'b', 'c'};
         String str = new String(data);
     
    69 为负
  •      char data[] = {'a', 'b', 'c'};
         String str = new String(data);
     
    80 大于
         char data[] = {'a', 'b', 'c'};
         String str = new String(data);
     
    81

getBytes

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
3使用指定的字符集将此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 编码为 byte 序列,并将结果存储到一个新的 byte 数组中。

当此字符串不能使用给定的字符集编码时,此方法的行为没有指定。如果需要对编码过程进行更多控制,则应该使用

     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
01 类。

参数:
     String str = "abc";
 
36 - 受支持的 charset 名称返回:所得 byte 数组抛出:
     String str = "abc";
 
37 - 如果指定的字符集不受支持从以下版本开始:JDK1.1

getBytes

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
4使用给定的 charset 将此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 编码到 byte 序列,并将结果存储到新的 byte 数组。

此方法总是使用此字符集的默认替代 byte 数组替代错误输入和不可映射字符序列。如果需要对编码过程进行更多控制,则应该使用

     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
01 类。

参数:
     String str = "abc";
 
48 - 用于编码
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 的 Charset返回:所得 byte 数组从以下版本开始:1.6

getBytes

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
5使用平台的默认字符集将此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 编码为 byte 序列,并将结果存储到一个新的 byte 数组中。

当此字符串不能使用默认的字符集编码时,此方法的行为没有指定。如果需要对编码过程进行更多控制,则应该使用

     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
01 类。

返回:所得 byte 数组从以下版本开始:JDK1.1

equals

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
6将此字符串与指定的对象比较。当且仅当该参数不为
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
10,并且是与此对象表示相同字符序列的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象时,结果才为
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12。覆盖:类
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
13 中的
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
14参数:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
15 - 与此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 进行比较的对象。返回:如果给定对象表示的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 与此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 相等,则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12;否则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
20。另请参见:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
21,
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
22

contentEquals

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
7将此字符串与指定的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
19 比较。当且仅当此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 与指定
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
19 表示相同的字符序列时,结果才为
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12。参数:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
27 - 要与此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 比较的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
19。返回:如果此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 与指定
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
19 表示相同的字符序列,则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12;否则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
20。从以下版本开始:1.4

contentEquals

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
8将此字符串与指定的
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
34 比较。当且仅当此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 与指定序列表示相同的 char 值序列时,结果才为
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12。参数:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
37 - 要与此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 比较的序列返回:如果此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 与指定序列表示相同的 char 值序列,则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12;否则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
20。从以下版本开始:1.5

equalsIgnoreCase

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
9将此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 与另一个
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 比较,不考虑大小写。如果两个字符串的长度相同,并且其中的相应字符都相等(忽略大小写),则认为这两个字符串是相等的。

在忽略大小写的情况下,如果下列至少一项为 true,则认为

     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
44 和
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
45 这两个字符相同。

参数:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
46 - 与此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 进行比较的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。返回:如果参数不为
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
10,且这两个
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 相等(忽略大小写),则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12;否则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
20。另请参见:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
53

compareTo

     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
0按字典顺序比较两个字符串。该比较基于字符串中各个字符的 Unicode 值。按字典顺序将此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象表示的字符序列与参数字符串所表示的字符序列进行比较。如果按字典顺序此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象位于参数字符串之前,则比较结果为一个负整数。如果按字典顺序此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象位于参数字符串之后,则比较结果为一个正整数。如果这两个字符串相等,则结果为 0;
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
57 只在方法
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
53 返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12 时才返回
     String str = "abc";
 
91。

这是字典排序的定义。如果这两个字符串不同,那么它们要么在某个索引处的字符不同(该索引对二者均为有效索引),要么长度不同,或者同时具备这两种情况。如果它们在一个或多个索引位置上的字符不同,假设 k 是这类索引的最小值;则在位置 k 上具有较小值的那个字符串(使用 < 运算符确定),其字典顺序在其他字符串之前。在这种情况下,

     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
57 返回这两个字符串在位置
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
62 处两个char 值的差,即值:

     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
1
如果没有字符不同的索引位置,则较短字符串的字典顺序在较长字符串之前。在这种情况下,
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
57 返回这两个字符串长度的差,即值:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
2
指定者:接口
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
64 中的
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
65参数:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
46 - 要比较的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。返回:如果参数字符串等于此字符串,则返回值
     String str = "abc";
 
91;如果此字符串按字典顺序小于字符串参数,则返回一个小于
     String str = "abc";
 
91 的值;如果此字符串按字典顺序大于字符串参数,则返回一个大于
     String str = "abc";
 
91 的值。

compareToIgnoreCase

     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
3按字典顺序比较两个字符串,不考虑大小写。此方法返回一个整数,其符号与使用规范化的字符串调用
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
57 所得符号相同,规范化字符串的大小写差异已通过对每个字符调用
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
72 消除。

注意,此方法不 考虑语言环境,因此可能导致在某些语言环境中的排序效果不理想。java.text 包提供 Collators 完成与语言环境有关的排序。

参数:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
73 - 要比较的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。返回:根据指定 String 大于、等于还是小于此 String(不考虑大小写),分别返回一个负整数、0 或一个正整数。从以下版本开始:1.2另请参见:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
66

regionMatches

     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
4测试两个字符串区域是否相等。

将此 String 对象的一个子字符串与参数 other 的一个子字符串进行比较。如果这两个子字符串表示相同的字符序列,则结果为 true。要比较的此 String 对象的子字符串从索引 toffset 处开始,长度为 len。要比较的 other 的子字符串从索引 ooffset 处开始,长度为 len。当且仅当下列至少一项为 true 时,结果才为 false :

  • toffset 为负。
  • ooffset 为负。
  • toffset+len 大于此 String 对象的长度。
  • ooffset+len 大于另一个参数的长度。
  • 存在某个小于 len 的非负整数 k,它满足:this.charAt(toffset+k) != other.charAt(ooffset+k)
参数:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
76 - 字符串中子区域的起始偏移量。
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
77 - 字符串参数。
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
78 - 字符串参数中子区域的起始偏移量。
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
79 - 要比较的字符数。返回:如果此字符串的指定子区域完全匹配字符串参数的指定子区域,则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12;否则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
20。

regionMatches

     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
5测试两个字符串区域是否相等。

将此 String 对象的子字符串与参数 other 的子字符串进行比较。如果这两个子字符串表示相同的字符序列,则结果为 true,当且仅当 ignoreCase 为 true 时忽略大小写。要比较的此 String 对象的子字符串从索引 toffset 处开始,长度为 len。要比较的 other 的子字符串从索引 ooffset 处开始,长度为 len。当且仅当下列至少一项为 true 时,结果才为 false:

  • toffset 为负。
  • ooffset 为负。
  • toffset+len 大于此 String 对象的长度。
  • ooffset+len 大于另一个参数的长度。
  • ignoreCase 为 false,且存在某个小于 len 的非负整数 k,即:
         System.out.println("abc");
         String cde = "cde";
         System.out.println("abc" + cde);
         String c = "abc".substring(2,3);
         String d = cde.substring(1, 2);
     
    6
  • ignoreCase 为 true,且存在某个小于 len 的非负整数 k,即:
         System.out.println("abc");
         String cde = "cde";
         System.out.println("abc" + cde);
         String c = "abc".substring(2,3);
         String d = cde.substring(1, 2);
     
    7
    以及:
         System.out.println("abc");
         String cde = "cde";
         System.out.println("abc" + cde);
         String c = "abc".substring(2,3);
         String d = cde.substring(1, 2);
     
    8
参数:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
82 - 如果为
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12,则比较字符时忽略大小写。
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
76 - 此字符串中子区域的起始偏移量。
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
77 - 字符串参数。
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
76 - 字符串参数中子区域的起始偏移量。
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
79 - 要比较的字符数。返回:如果此字符串的指定子区域匹配字符串参数的指定子区域,则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12;否则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
20。是否完全匹配或考虑大小写取决于
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
82 参数。

startsWith

     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
9测试此字符串从指定索引开始的子字符串是否以指定前缀开始。参数:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
91 - 前缀。
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
76 - 在此字符串中开始查找的位置。返回:如果参数表示的字符序列是此对象从索引
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
76 处开始的子字符串前缀,则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12;否则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
20。如果
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
76 为负或大于此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象的长度,则结果为
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
20;否则结果与以下表达式的结果相同:
public static final Comparator<String> CASE_INSENSITIVE_ORDER
0

startsWith

public static final Comparator<String> CASE_INSENSITIVE_ORDER
1测试此字符串是否以指定的前缀开始。参数:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
91 - 前缀。返回:如果参数表示的字符序列是此字符串表示的字符序列的前缀,则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12;否则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
20。还要注意,如果参数是空字符串,或者等于此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象(用
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
53 方法确定),则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12。从以下版本开始:1. 0

endsWith

public static final Comparator<String> CASE_INSENSITIVE_ORDER
2测试此字符串是否以指定的后缀结束。参数:
public static final Comparator<String> CASE_INSENSITIVE_ORDER
05 - 后缀。返回:如果参数表示的字符序列是此对象表示的字符序列的后缀,则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12;否则返回
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
20。注意,如果参数是空字符串,或者等于此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象(用
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
53 方法确定),则结果为
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12。

hashCode

public static final Comparator<String> CASE_INSENSITIVE_ORDER
3返回此字符串的哈希码。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象的哈希码根据以下公式计算:
public static final Comparator<String> CASE_INSENSITIVE_ORDER
4
使用
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
88 算法,这里
public static final Comparator<String> CASE_INSENSITIVE_ORDER
13 是字符串的第 i 个字符,
public static final Comparator<String> CASE_INSENSITIVE_ORDER
14 是字符串的长度,
public static final Comparator<String> CASE_INSENSITIVE_ORDER
15 表示求幂。(空字符串的哈希值为 0。)覆盖:类
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
13 中的
public static final Comparator<String> CASE_INSENSITIVE_ORDER
17返回:此对象的哈希码值。另请参见:
public static final Comparator<String> CASE_INSENSITIVE_ORDER
18,
public static final Comparator<String> CASE_INSENSITIVE_ORDER
19

indexOf

public static final Comparator<String> CASE_INSENSITIVE_ORDER
5返回指定字符在此字符串中第一次出现处的索引。如果在此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象表示的字符序列中出现值为
public static final Comparator<String> CASE_INSENSITIVE_ORDER
21 的字符,则返回第一次出现该字符的索引(以 Unicode 代码单元表示)。对于 0 到 0xFFFF(包括 0 和 0xFFFF)范围内的
public static final Comparator<String> CASE_INSENSITIVE_ORDER
21 的值,返回值是
public static final Comparator<String> CASE_INSENSITIVE_ORDER
6
为 true 的最小 k 值。对于其他
public static final Comparator<String> CASE_INSENSITIVE_ORDER
21 值,返回值是
public static final Comparator<String> CASE_INSENSITIVE_ORDER
7
为 true 最小 k 值。无论哪种情况,如果此字符串中没有这样的字符,则返回
public static final Comparator<String> CASE_INSENSITIVE_ORDER
24。参数:
public static final Comparator<String> CASE_INSENSITIVE_ORDER
21 - 一个字符(Unicode 代码点)。返回:在此对象表示的字符序列中第一次出现该字符的索引;如果未出现该字符,则返回
public static final Comparator<String> CASE_INSENSITIVE_ORDER
24。

indexOf

public static final Comparator<String> CASE_INSENSITIVE_ORDER
8返回在此字符串中第一次出现指定字符处的索引,从指定的索引开始搜索。

在此

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象表示的字符序列中,如果带有值
public static final Comparator<String> CASE_INSENSITIVE_ORDER
21 的字符的索引不小于
public static final Comparator<String> CASE_INSENSITIVE_ORDER
29,则返回第一次出现该值的索引。对于 0 到 0xFFFF(包括 0 和 0xFFFF)范围内的
public static final Comparator<String> CASE_INSENSITIVE_ORDER
21 值,返回值是

public static final Comparator<String> CASE_INSENSITIVE_ORDER
9
为 true 的最小 k 值。对于其他
public static final Comparator<String> CASE_INSENSITIVE_ORDER
21 值,返回值是
public String()
0
为 true 的最小 k 值。无论哪种情况,如果此字符串中
public static final Comparator<String> CASE_INSENSITIVE_ORDER
29 或之后的位置没有这样的字符出现,则返回
public static final Comparator<String> CASE_INSENSITIVE_ORDER
24。

public static final Comparator<String> CASE_INSENSITIVE_ORDER
29 的值没有限制。如果它为负,则与它为 0 的效果同样:将搜索整个字符串。如果它大于此字符串的长度,则与它等于此字符串长度的效果相同:返回
public static final Comparator<String> CASE_INSENSITIVE_ORDER
24。

所有索引都在

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值中指定(Unicode 代码单元)。

参数:
public static final Comparator<String> CASE_INSENSITIVE_ORDER
21 - 一个字符(Unicode 代码点)。
public static final Comparator<String> CASE_INSENSITIVE_ORDER
29 - 开始搜索的索引。返回:在此对象表示的字符序列中第一次出现的大于或等于
public static final Comparator<String> CASE_INSENSITIVE_ORDER
29 的字符的索引;如果未出现该字符,则返回
public static final Comparator<String> CASE_INSENSITIVE_ORDER
24。

lastIndexOf

public String()
1返回指定字符在此字符串中最后一次出现处的索引。对于 0 到 0xFFFF(包括 0 和 0xFFFF)范围内的
public static final Comparator<String> CASE_INSENSITIVE_ORDER
21 的值,返回的索引(Unicode 代码单元)是
public static final Comparator<String> CASE_INSENSITIVE_ORDER
6
为 true 最大 k 值。对于其他
public static final Comparator<String> CASE_INSENSITIVE_ORDER
21 值,返回值是
public static final Comparator<String> CASE_INSENSITIVE_ORDER
7
为 true 的最大 k 值。无论哪种情况,如果此字符串中没有这样的字符出现,则返回
public static final Comparator<String> CASE_INSENSITIVE_ORDER
24。从最后一个字符开始反向搜索此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。参数:
public static final Comparator<String> CASE_INSENSITIVE_ORDER
21 - 一个字符(Unicode 代码点)。返回:在此对象表示的字符序列中最后一次出现该字符的索引;如果未出现该字符,则返回
public static final Comparator<String> CASE_INSENSITIVE_ORDER
24。

lastIndexOf

public String()
4返回指定字符在此字符串中最后一次出现处的索引,从指定的索引处开始进行反向搜索。对于 0 到 0xFFFF(包括 0 和 0xFFFF)范围内的
public static final Comparator<String> CASE_INSENSITIVE_ORDER
21 值,返回的索引是
public String()
5
为 true 的最大 k 值。对于
public static final Comparator<String> CASE_INSENSITIVE_ORDER
21 的其他值,返回值是
public String()
6
为 true 的最大 k 值。无论哪种情况,如果此字符串中
public static final Comparator<String> CASE_INSENSITIVE_ORDER
29 或之前的位置没有这样的字符出现,则返回
public static final Comparator<String> CASE_INSENSITIVE_ORDER
24。

所有的索引都以

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 值指定(Unicode 代码单元)。

参数:
public static final Comparator<String> CASE_INSENSITIVE_ORDER
21 - 一个字符(Unicode 代码点)。
public static final Comparator<String> CASE_INSENSITIVE_ORDER
29 - 开始搜索的索引。
public static final Comparator<String> CASE_INSENSITIVE_ORDER
29 的值没有限制。如果它大于等于此字符串的长度,则与它小于此字符串长度减 1 的效果相同:将搜索整个字符串。如果它为负,则与它为 -1 的效果相同:返回 -1。返回:在此对象表示的字符序列(小于等于
public static final Comparator<String> CASE_INSENSITIVE_ORDER
29)中最后一次出现该字符的索引;如果在该点之前未出现该字符,则返回
public static final Comparator<String> CASE_INSENSITIVE_ORDER
24。

indexOf

public String()
7返回指定子字符串在此字符串中第一次出现处的索引。返回的整数是
public String()
8
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12 的最小 k 值。参数:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
73 - 任意字符串。返回:如果字符串参数作为一个子字符串在此对象中出现,则返回第一个这种子字符串的第一个字符的索引;如果它不作为一个子字符串出现,则返回
public static final Comparator<String> CASE_INSENSITIVE_ORDER
24。

indexOf

public String()
9返回指定子字符串在此字符串中第一次出现处的索引,从指定的索引开始。返回的整数是满足下式的最小 k 值:
public String(String original)
0
如果不存在这样的 k 值,则返回 -1。参数:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
73 - 要搜索的子字符串。
public static final Comparator<String> CASE_INSENSITIVE_ORDER
29 - 开始搜索的索引位置。返回:指定子字符串在此字符串中第一次出现处的索引,从指定的索引开始。

lastIndexOf

public String(String original)
1返回指定子字符串在此字符串中最右边出现处的索引。将最右边的空字符串 "" 视为出现在索引值
public static final Comparator<String> CASE_INSENSITIVE_ORDER
62 处。返回的索引是
public String(String original)
2
为 true 的最大 k 值。参数:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
73 - 要搜索的子字符串。返回:如果字符串参数作为一个子字符串在此对象中出现一次或多次,则返回最后一个这种子字符串的第一个字符。如果它不作为一个子字符串出现,则返回
public static final Comparator<String> CASE_INSENSITIVE_ORDER
24。

lastIndexOf

public String(String original)
3返回指定子字符串在此字符串中最后一次出现处的索引,从指定的索引开始反向搜索。返回的整数是满足下式的最大 k 值:
public String(String original)
4
如果不存在这样的 k 值,则返回 -1。参数:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
73 - 要搜索的子字符串。
public static final Comparator<String> CASE_INSENSITIVE_ORDER
29 - 开始搜索的索引位置。返回:指定子字符串在此字符串中最后一次出现处的索引。

substring

public String(String original)
5返回一个新的字符串,它是此字符串的一个子字符串。该子字符串从指定索引处的字符开始,直到此字符串末尾。

示例:

public String(String original)
6
参数:
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
33 - 起始索引(包括)。返回:指定的子字符串。抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
33 为负或大于此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象的长度。

substring

public String(String original)
7返回一个新字符串,它是此字符串的一个子字符串。该子字符串从指定的
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
33 处开始,直到索引
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
34 处的字符。因此,该子字符串的长度为
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
37。

示例:

public String(String original)
8
参数:
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
33 - 起始索引(包括)。
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
40 - 结束索引(不包括)。返回:指定的子字符串。抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
33 为负,或
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
40 大于此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象的长度,或
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
33 大于
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
40。

subSequence

public String(String original)
9返回一个新的字符序列,它是此序列的一个子序列。

此方法这种形式的调用:

public String(char[] value)
0
与以下调用的行为完全相同:
public String(char[] value)
1
定义此方法使 String 类能够实现
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
34 接口。指定者:接口
     String str = "abc";
 
86 中的
public static final Comparator<String> CASE_INSENSITIVE_ORDER
84参数:
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
33 - 起始索引(包括)。
     char data[] = {'a', 'b', 'c'};
     String str = new String(data);
 
40 - 结束索引(不包括)。返回:指定子序列。抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果 beginIndex 或 endIndex 为负,如果 endIndex 大于 length() 或 beginIndex 大于 startIndex从以下版本开始:1.4

concat

public String(char[] value)
2将指定字符串连接到此字符串的结尾。

如果参数字符串的长度为

     String str = "abc";
 
91,则返回此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象。否则,创建一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象,用来表示由此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象表示的字符序列和参数字符串表示的字符序列连接而成的字符序列。

示例:

public String(char[] value)
3
参数:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
73 - 连接到此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 结尾的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。返回:一个字符串,它表示在此对象字符后连接字符串参数字符而成的字符。

replace

public String(char[] value)
4返回一个新的字符串,它是通过用
public static final Comparator<String> CASE_INSENSITIVE_ORDER
95 替换此字符串中出现的所有
public static final Comparator<String> CASE_INSENSITIVE_ORDER
96 得到的。

如果

public static final Comparator<String> CASE_INSENSITIVE_ORDER
96 在此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象表示的字符序列中没有出现,则返回对此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象的引用。否则,创建一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象,它所表示的字符序列除了所有的
public static final Comparator<String> CASE_INSENSITIVE_ORDER
96 都被替换为
public static final Comparator<String> CASE_INSENSITIVE_ORDER
95 之外,与此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象表示的字符序列相同。

示例:

public String(char[] value)
5
参数:
public static final Comparator<String> CASE_INSENSITIVE_ORDER
96 - 原字符。
public static final Comparator<String> CASE_INSENSITIVE_ORDER
95 - 新字符。返回:一个从此字符串派生的字符串,它将此字符串中的所有
public static final Comparator<String> CASE_INSENSITIVE_ORDER
96 替代为
public static final Comparator<String> CASE_INSENSITIVE_ORDER
95。

matches

public String(char[] value)
6告知此字符串是否匹配给定的正则表达式。

调用此方法的 str.matches(regex) 形式与以下表达式产生的结果完全相同:

public String()
08.
public String()
09(regex, str)
参数:
public String()
10 - 用来匹配此字符串的正则表达式返回:当且仅当此字符串匹配给定的正则表达式时,返回 true抛出:
public String()
11 - 如果正则表达式的语法无效从以下版本开始:1.4另请参见:
public String()
08

contains

public String(char[] value)
7当且仅当此字符串包含指定的 char 值序列时,返回 true。参数:
public String()
13 - 要搜索的序列返回:如果此字符串包含
public String()
13,则返回 true,否则返回 false抛出:
public String()
15 - 如果
public String()
13 为
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
10从以下版本开始:1.5

replaceFirst

public String(char[] value)
8使用给定的 replacement 替换此字符串匹配给定的正则表达式的第一个子字符串。

调用此方法的 str.replaceFirst(regex, repl) 形式与以下表达式产生的结果完全相同:

public String()
08.
public String()
19(regex).
public String()
20(str).
public String()
21(repl)

注意,在替代字符串中使用反斜杠 (\) 和美元符号 ($) 与将其视为字面值替代字符串所得的结果可能不同;请参阅

public String()
22。如有需要,可使用
public String()
23 取消这些字符的特殊含义。

参数:
public String()
10 - 用来匹配此字符串的正则表达式
public String()
25 - 用来替换第一个匹配项的字符串返回:所得 String抛出:
public String()
11 - 如果正则表达式的语法无效从以下版本开始:1.4另请参见:
public String()
08

replaceAll

public String(char[] value)
9使用给定的 replacement 替换此字符串所有匹配给定的正则表达式的子字符串。

调用此方法的 str.replaceAll(regex, repl) 形式与以下表达式产生的结果完全相同:

public String()
08.
public String()
19(regex).
public String()
20(str).
public String()
31(repl)

注意,在替代字符串中使用反斜杠 (\) 和美元符号 ($) 与将其视为字面值替代字符串所得的结果可能不同;请参阅

public String()
32。如有需要,可使用
public String()
23 取消这些字符的特殊含义。

参数:
public String()
10 - 用来匹配此字符串的正则表达式
public String()
25 - 用来替换每个匹配项的字符串返回:所得 String抛出:
public String()
11 - 如果正则表达式的语法无效从以下版本开始:1.4另请参见:
public String()
08

replace

public String(char[] value,
              int offset,
              int count)
0使用指定的字面值替换序列替换此字符串所有匹配字面值目标序列的子字符串。该替换从字符串的开头朝末尾执行,例如,用 "b" 替换字符串 "aaa" 中的 "aa" 将生成 "ba" 而不是 "ab"。参数:
public String()
38 - 要被替换的 char 值序列
public String()
25 - char 值的替换序列返回:所得 String抛出:
public String()
15 - 如果
public String()
38 或
public String()
25 为
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
10。从以下版本开始:1.5

split

public String(char[] value,
              int offset,
              int count)
1根据匹配给定的正则表达式来拆分此字符串。

此方法返回的数组包含此字符串的子字符串,每个子字符串都由另一个匹配给定表达式的子字符串终止,或者由此字符串末尾终止。数组中的子字符串按它们在此字符串中出现的顺序排列。如果表达式不匹配输入的任何部分,那么所得数组只具有一个元素,即此字符串。

limit 参数控制模式应用的次数,因此影响所得数组的长度。如果该限制 n 大于 0,则模式将被最多应用 n - 1 次,数组的长度将不会大于 n,而且数组的最后一项将包含所有超出最后匹配的定界符的输入。如果 n 为非正,那么模式将被应用尽可能多的次数,而且数组可以是任何长度。如果 n 为 0,那么模式将被应用尽可能多的次数,数组可以是任何长度,并且结尾空字符串将被丢弃。

例如,字符串 "boo:and:foo" 使用这些参数可生成以下结果:

RegexLimit结果:2{ "boo", "and:foo" }:5{ "boo", "and", "foo" }:-2{ "boo", "and", "foo" }o5{ "b", "", ":and:f", "", "" }o-2{ "b", "", ":and:f", "", "" }o0{ "b", "", ":and:f" }

调用此方法的 str.split(regex, n) 形式与以下表达式产生的结果完全相同:

public String()
08.
public String()
19(regex).
public String()
46(str, n)
参数:
public String()
10 - 定界正则表达式
public String()
48 - 结果阈值,如上所述返回:字符串数组,它是根据给定正则表达式的匹配拆分此字符串确定的抛出:
public String()
11 - 如果正则表达式的语法无效从以下版本开始:1.4另请参见:
public String()
08

split

public String(char[] value,
              int offset,
              int count)
2根据给定正则表达式的匹配拆分此字符串。

该方法的作用就像是使用给定的表达式和限制参数 0 来调用两参数

public String()
46 方法。因此,所得数组中不包括结尾空字符串。

例如,字符串 "boo:and:foo" 使用这些表达式可生成以下结果:

Regex结果:{ "boo", "and", "foo" }o{ "b", "", ":and:f" }
参数:
public String()
10 - 定界正则表达式返回:字符串数组,它是根据给定正则表达式的匹配拆分此字符串确定的抛出:
public String()
11 - 如果正则表达式的语法无效从以下版本开始:1.4另请参见:
public String()
08

toLowerCase

public String(char[] value,
              int offset,
              int count)
3使用给定
public String()
55 的规则将此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 中的所有字符都转换为小写。大小写映射关系基于
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
17 类指定的 Unicode 标准版。由于大小写映射关系并不总是 1:1 的字符映射关系,因此所得
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 的长度可能不同于原
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。

下表中给出了几个小写映射关系的示例:

语言环境的代码大写字母小写字母描述tr (Turkish)\u0130\u0069大写字母 I,上面有点 -> 小写字母 itr (Turkish)\u0049\u0131大写字母 I -> 小写字母 i,无点(all)French Friesfrench fries将字符串中的所有字符都小写(all)
String java中文
String java中文
String java中文
String java中文
String java中文
String java中文
String java中文
String java中文
String java中文
String java中文
将字符串中的所有字符都小写参数:
public String()
60 - 使用此语言环境的大小写转换规则返回:要转换为小写的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。从以下版本开始:1.1另请参见:
public String()
62,
public String()
63,
public String()
64

toLowerCase

public String(char[] value,
              int offset,
              int count)
4使用默认语言环境的规则将此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 中的所有字符都转换为小写。这等效于调用
public String()
66。

注: 此方法与语言环境有关,如果用于应独立于语言环境解释的字符串,则可能生成不可预料的结果。 示例有编程语言标识符、协议键、HTML 标记。 例如,

public String()
67 在 Turkish(土耳其语)语言环境中返回
public String()
68,其中“?”是 LATIN SMALL LETTER DOTLESS I 字符。 对于与语言环境有关的字符,要获得正确的结果,请使用
public String()
69。

返回:要转换为小写的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。另请参见:
public String()
71

toUpperCase

public String(char[] value,
              int offset,
              int count)
5使用给定
public String()
55 的规则将此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 中的所有字符都转换为大写。大小写映射关系基于
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
17 类指定的 Unicode 标准版。由于大小写映射关系并不总是 1:1 的字符映射关系,因此所得
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 的长度可能不同于原
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。

下表中给出了几个与语言环境有关和 1:M 大小写映射关系的一些示例。

语言环境的代码小写大写描述tr (Turkish)\u0069\u0130小写字母 i -> 大写字母 I,上面有点tr (Turkish)\u0131\u0049小写字母 i,无点 -> 大写字母 I(all)\u00df\u0053 \u0053小写字母 sharp s -> 两个字母:SS(all)FahrvergnügenFAHRVERGNÜN参数:
public String()
60 - 使用此语言环境的大小写转换规则返回:要转换为大写的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。从以下版本开始:1.1另请参见:
public String()
63,
public String()
62,
public String()
71

toUpperCase

public String(char[] value,
              int offset,
              int count)
6使用默认语言环境的规则将此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 中的所有字符都转换为大写。此方法等效于
public String()
83。

注: 此方法与语言环境有关,如果用于应独立于语言环境解释的字符串,则可能生成不可预料的结果。 示例有编程语言标识符、协议键、HTML 标记。 例如,

public String()
84 在 Turkish(土耳其语)语言环境中返回
public String()
85,其中“?”是 LATIN CAPITAL LETTER I WITH DOT ABOVE 字符。 对于与语言环境有关的字符,要获得正确的结果,请使用
public String()
86。

返回:要转换为大写的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14。另请参见:
public String()
64

trim

public String(char[] value,
              int offset,
              int count)
7返回字符串的副本,忽略前导空白和尾部空白。

如果此

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象表示一个空字符序列,或者此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象表示的字符序列的第一个和最后一个字符的代码都大于
public String()
91(空格字符),则返回对此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象的引用。

否则,若字符串中没有代码大于

public String()
91 的字符,则创建并返回一个表示空字符串的新
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象。

否则,假定 k 为字符串中代码大于

public String()
91 的第一个字符的索引,m 为字符串中代码大于
public String()
91 的最后一个字符的索引。创建一个新的
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象,它表示此字符串中从索引 k 处的字符开始,到索引 m 处的字符结束的子字符串,即
public String()
98 的结果。

此方法可用于截去字符串开头和末尾的空白(如上所述)。

返回:此字符串移除了前导和尾部空白的副本;如果没有前导和尾部空白,则返回此字符串。

toString

public String(char[] value,
              int offset,
              int count)
8返回此对象本身(它已经是一个字符串!)。指定者:接口
     String str = "abc";
 
86 中的
public String(String original)
00覆盖:类
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
13 中的
public String(String original)
02返回:字符串本身。

toCharArray

public String(char[] value,
              int offset,
              int count)
9将此字符串转换为一个新的字符数组。返回:一个新分配的字符数组,它的长度是此字符串的长度,它的内容被初始化为包含此字符串表示的字符序列。

format

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
00使用指定的格式字符串和参数返回一个格式化字符串。

始终使用

public String(String original)
03 返回的语言环境。

参数:
public String(String original)
04 - 格式字符串
public String(String original)
05 - 格式字符串中由格式说明符引用的参数。如果还有格式说明符以外的参数,则忽略这些额外的参数。参数的数目是可变的,可以为 0。参数的最大数目受 Java Virtual Machine Specification 所定义的 Java 数组最大维度的限制。有关 null 参数的行为依赖于转换。返回:一个格式化字符串抛出:
public String(String original)
06 - 如果格式字符串中包含非法语法、与给定的参数不兼容的格式说明符,格式字符串给定的参数不够,或者存在其他非法条件。有关所有可能的格式化错误的规范,请参阅 formatter 类规范的详细信息 一节。
public String()
15 - 如果 format 为 null从以下版本开始:1.5另请参见:
public String(String original)
08

format

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
01使用指定的语言环境、格式字符串和参数返回一个格式化字符串。参数:
public String(String original)
09 - 格式化过程中要应用的语言环境。如果 l 为 null,则不进行本地化。
public String(String original)
04 - 格式字符串
public String(String original)
05 - 格式字符串中由格式说明符引用的参数。如果还有格式说明符以外的参数,则忽略这些额外的参数。参数的数目是可变的,可以为 0。参数的最大数目受 Java Virtual Machine Specification 所定义的 Java 数组最大维度的限制。有关 null 参数的行为依赖于转换。返回:一个格式化字符串抛出:
public String(String original)
06 - 如果格式字符串中包含非法语法、与给定参数不兼容的格式说明符,格式字符串给定的参数不够,或存在其他非法条件。有关所有可能的格式化错误的规范,请参阅 formatter 类规范的详细信息 一节。
public String()
15 - 如果 format 为 null从以下版本开始:1.5另请参见:
public String(String original)
08

valueOf

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
02返回
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
22 参数的字符串表示形式。参数:
public String(String original)
16 - 一个
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
22。返回:如果参数为
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
10,则字符串等于
public String(String original)
19;否则,返回
public String(String original)
20 的值。另请参见:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
30

valueOf

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
03返回
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 数组参数的字符串表示形式。字符数组的内容已被复制,后续修改不会影响新创建的字符串。参数:
public String(String original)
23 -
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 数组。返回:一个新分配的字符串,它表示包含在字符数组参数中的相同字符序列。

valueOf

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
04返回
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 数组参数的特定子数组的字符串表示形式。

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 参数是子数组的第一个字符的索引。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
76 参数指定子数组的长度。字符数组的内容已被复制,后续修改不会影响新创建的字符串。

参数:
public String(String original)
23 - 字符数组。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 -
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 值的初始偏移量。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
76 -
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 值的长度。返回:一个字符串,它表示在字符数组参数的子数组中包含的字符序列。抛出:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
80 - 如果
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 为负,
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
76 为负,或者
public String(String original)
36 大于
public String(String original)
37。

copyValueOf

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
05返回指定数组中表示该字符序列的 String。参数:
public String(String original)
23 - 字符数组。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
75 - 子数组的初始偏移量。
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
76 - 子数组的长度。返回:一个
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14,它包含字符数组的指定子数组的字符。

copyValueOf

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
06返回指定数组中表示该字符序列的 String。参数:
public String(String original)
23 - 字符数组。返回:一个
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14,它包含字符数组的字符。

valueOf

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
07返回
public String(String original)
44 参数的字符串表示形式。参数:
public String(String original)
45 - 一个
public String(String original)
44。返回:如果参数为
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12,则返回一个等于
public String(String original)
48 的字符串;否则,返回一个等于
public String(String original)
49 的字符串。

valueOf

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
08返回
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26 参数的字符串表示形式。参数:
public String(String original)
51 - 一个
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
26。返回:一个长度为
     String str = "abc";
 
95 的字符串,它包含参数
public String(String original)
51 的单个字符。

valueOf

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
09返回
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
88 参数的字符串表示形式。

该表示形式恰好是单参数的

public String(String original)
56 方法返回的结果。

参数:
public String(String original)
57 - 一个
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
88。返回:
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
88 参数的字符串表示形式。另请参见:
public String(String original)
60

valueOf

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
10返回
public String(String original)
61 参数的字符串表示形式。

该表示形式恰好是单参数的

public String(String original)
62 方法返回的结果。

参数:
public String(String original)
09 - 一个
public String(String original)
61。返回:
public String(String original)
61 参数的字符串表示形式。另请参见:
public String(String original)
66

valueOf

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
11返回
public String(String original)
67 参数的字符串表示形式。

该表示形式恰好是单参数的

public String(String original)
68 方法返回的结果。

参数:
public String(String original)
69 - 一个
public String(String original)
67。返回:
public String(String original)
67 参数的字符串表示形式。另请参见:
public String(String original)
72

valueOf

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
12返回
public String(String original)
73 参数的字符串表示形式。

该表示形式恰好是单参数的

public String(String original)
74 方法返回的结果。

参数:
public String(String original)
75 - 一个
public String(String original)
73。返回:
public String(String original)
73 参数的字符串表示形式。另请参见:
public String(String original)
78

intern

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
13返回字符串对象的规范化表示形式。

一个初始为空的字符串池,它由类

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 私有地维护。

当调用 intern 方法时,如果池已经包含一个等于此

public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象的字符串(用
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
53 方法确定),则返回池中的字符串。否则,将此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象添加到池中,并返回此
public final class Stringextends Objectimplements Serializable, Comparable<String>, CharSequence
14 对象的引用。

它遵循以下规则:对于任意两个字符串

public String()
13 和
public String(String original)
85,当且仅当
public String(String original)
86 为
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12 时,
public String(String original)
88 才为
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);
 
12。