bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java String subSequence() Method

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Java String subSequence() Method?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___ myStr = "Hello, World!";
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The subSequence() method returns a subsequence from the string as a CharSequence object.
Definition and Usage
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