String.substring()

Signature

String substring (String s1, int beginIndex, int endIndex)

Domain

action, condition

Description

Returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex - beginIndex.

Parameters

NameTypeDescription
s1StringA String to use as a source of the substring.
beginIndexintThe String index where the substring should start. The index is zero-based.
endIndexintThe String index where the substring should end. The index is zero-based.

Returns

TypeDescription
StringA new string that is a substring of this string starting at beginIndex and continuing to endIndex.

Cautions

none

Example


String result = String.substring ("This is a test", 5, 9);

Result is:
result contains: "is a"