StringBuilder类subSequence()方法 (StringBuilder Class subSequence() method)
- subSequence() method is available in java.lang package. - subSequence()方法在java.lang包中可用。 
- subSequence() method is used to return the new set of a character sequence that is a subset of this sequence. - subSequence()方法用于返回字符序列的新集合,该字符序列是该序列的子集。 
- subSequence() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error. - subSequence()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。 
- subSequence() method may throw an exception at the time of character sequence. - subSequence()方法在字符序列时可能会引发异常。 - IndexOutOfBoundsException – This exception may throw when end_seq > length or when st_seq > end_seq or when st_seq or end_seq are less than 0. - IndexOutOfBoundsException-当end_seq> length或st_seq> end_seq或st_seq或end_seq小于0时,可能引发此异常。 
Syntax:
句法:
    public CharSequence subSequence(int st_seq, int end_seq);
Parameter(s):
参数:
- int st_seq – represents the beginning index of this character sequence. - int st_seq –表示此字符序列的开始索引。 
- int end_seq – represents the ending index of this character sequence. - int end_seq –表示此字符序列的结束索引。 
Return value:
返回值:
The return type of this method is CharSequence, it returns the given subsequence of this character sequence.
此方法的返回类型为CharSequence ,它返回此字符序列的给定子序列。
Example:
例:
// Java program to demonstrate the example 
// of subSequence(int st_seq, int end_seq)
// method of StringBuilder 
public class SubSequence {
public static void main(String[] args) {
// Creating an StringBuilder object
StringBuilder st_b = new StringBuilder("Java World ");
// Display st_b object
System.out.println("st_b = " + st_b);
// By using subSequence() method is to return the sequence 
// from the given index 0 to index 3 (but it does not include
// last index i.e. 4)
CharSequence cs = st_b.subSequence(0, 4);
System.out.println("st_b.subSequence(0,4) = " + cs);
}
}
Output
输出量
st_b = Java World 
st_b.subSequence(0,4) = Java
翻译自: https://www.includehelp.com/java/stringbuilder-subsequence-method-with-example.aspx