CharSequence subSequence(int beginIndex, int endIndex)

本页内容

Java subSequence() 方法

Java String类

subSequence() 方法返回一个新的字符序列,它是此序列的一个子序列。

语法

public CharSequence subSequence(int beginIndex, int endIndex)

参数

  • beginIndex -- 起始索引(包括)。
  • endIndex -- 结束索引(不包括)。

返回值

返回一个新的字符序列,它是此序列的一个子序列。

==

public class Test {
    public static void main(String args[]) {
         String Str = new String("www.xiaobai.wang");

         System.out.print("返回值 :" );
         System.out.println(Str.subSequence(4, 10) );
    }
}

以上程序执行结果为:

返回值 :xiaobai

Java String类

此页面最后编辑于2022年8月17日 (星期三) 17:02。