Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Java subSequence() Method

Java subSequence() Method

Java String ClassJava String class


The subSequence() method returns a new character sequence that is a subsequence of this sequence.

Syntax


public CharSequence subSequence(int beginIndex, int endIndex)

Parameters

Return Value

Returns a new character sequence that is a subsequence of this sequence.

Example


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

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

The execution result of the above program is:


返回值 :runoob

Java String ClassJava String class