Java String.subSequence(int beginIndex, int endIndex)
Syntax
String.subSequence(int beginIndex, int endIndex) has the following syntax.
public CharSequence subSequence(int beginIndex, int endIndex)
Example
In the following code shows how to use String.subSequence(int beginIndex, int endIndex) method.
//from w ww .j ava 2 s .c om
public class Main {
public static void main(String[] args) {
String str = "java2s.com";
System.out.println("string = " + str);
// returns the specified subsequence from index 2 to 9
System.out.println("string subsequence = " + str.subSequence(2,9));
}
}
The code above generates the following result.