Share via


String.substring

Class Overview | Class Members | This Package | All Packages

Syntax 1

public String substring( int beginIndex )

Parameters
  • beginIndex
    the beginning index, inclusive.
Returns

the specified substring.

Description

Returns a new string that is a substring of this string. The substring begins at the specified index and extends to the end of this string.

Exceptions

StringIndexOutOfBoundsException if the beginIndex is out of range.

Syntax 2

public String substring( int beginIndex**, int** endIndex )

Parameters
  • beginIndex
    the beginning index, inclusive.
  • endIndex
    the ending index, exclusive.
Returns

the specified substring.

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.

Exceptions

StringIndexOutOfBoundsException if the beginIndex or the endIndex is out of range.