Java StringsubSequence() Method
Example
Return a sequence of characters from a string:
String myStr = "Hello, World!";System.out.println(myStr.subSequence(7, 12));Definition and Usage
ThesubSequence() method returns a subsequence from the string as aCharSequence object.
Syntax
public CharSequence subSequence(intstart, intend)Parameter Values
| Parameter | Description |
|---|---|
| start | Required. The index of the character at which the subsequence starts. |
| end | Required. The index after the last character of the subsequence. |
Technical Details
| Returns: | ACharSequence containing a subsequence of the string. |
|---|---|
| Throws: | IndexOutOfBoundsException - Ifstart orend are negative,start is greater thanend orend is greater than the length of the string. |
| Java version: | 1.4 |
❮ String Methods

