String.subSequence(int beginIndex, int endIndex) has the following syntax.
public CharSequence subSequence(int beginIndex, int endIndex)
In the following code shows how to use String.subSequence(int beginIndex, int endIndex) method.
// www . ja va2 s. c o m 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.