Java subSequence() Method
The subSequence() method returns a new character sequence that is a subsequence of this sequence.
Syntax
public CharSequence subSequence(int beginIndex, int endIndex)
Parameters
-
beginIndex -- The start index (inclusive).
-
endIndex -- The end index (exclusive).
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 class