bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java String subSequence() Method

❮ String Methods

Example

String myStr = "Hello, World!";
System.out.println(myStr.subSequence(7, 12));

Definition and Usage

The subSequence() method returns a subsequence from the string as a CharSequence object.

Syntax

public CharSequence subSequence(int
start , int
end )

Parameter Values

ParameterDescription
startRequired. The index of the character at which the subsequence starts.
endRequired. The index after the last character of the subsequence.

Technical Details

Returns:A CharSequence containing a subsequence of the string.
Throws:IndexOutOfBoundsException - If start or end are negative, start is greater than end or end is greater than the length of the string.
Java version:1.4

Previous

Java String startsWith() Method

Next

Java String substring() Method