[Chapter 12] StringIndexOutOfBoundsException

#

| Chapter 12 The java.lang Package |

# StringIndexOutOfBoundsException

## Name

StringIndexOutOfBoundsException

## Synopsis

Class Name:

  `java.lang.StringIndexOutOfBoundsException`

Superclass:

  `java.lang.IndexOutOfBoundsException`

Immediate Subclasses:

  None

Interfaces Implemented:

  None

Availability:

  JDK 1.0 or later

## Description

A `StringIndexOutOfBoundsException` is thrown when a `String` or `StringBuffer` object detects an out-of-range index. An out-of-range index occurs when the index is less than zero, or greater than or equal to the length of the string.

## Class Summary

    public class java.lang.StringIndexOutOfBoundsException
                 extends java.lang.IndexOutOfBoundsException {
      // Constructors
      public StringIndexOutOfBoundsException();
      public StringIndexOutOfBoundsException(int index);
      public StringIndexOutOfBoundsException(String s);
    }

## Constructors

### StringIndexOutOfBoundsException

#### public StringIndexOutOfBoundsException()

Description

  This constructor creates a `StringIndexOutOfBoundsException` with no associated detail message.

#### public StringIndexOutOfBoundsException(int index)

Parameters

  `index`

    The index value that was out of bounds

Description

  This constructor creates an `StringIndexOutOfBoundsException` with an associated message that mentions the specified index.

#### public StringIndexOutOfBoundsException(String s)

Parameters

  `s`

    The detail message.

Description

  This constructor creates a `StringIndexOutOfBoundsException` with the specified detail message.

## Inherited Methods

Method | Inherited From | Method | Inherited From
--- | --- | --- | ---
`clone()` | `Object` | `equals(Object)` | `Object`
`fillInStackTrace()` | `Throwable` | `finalize()` | `Object`
`getClass()` | `Object` | `getLocalizedMessage()` | `Throwable`
`getMessage()` | `Throwable` | `hashCode()` | `Object`
`notify()` | `Object` | `notifyAll()` | `Object`
`printStackTrace()` | `Throwable` | `printStackTrace(PrintStream)` | `Throwable`
`printStackTrace(PrintWriter)` | `Throwable` | `toString()` | `Object`
`wait()` | `Object` | `wait(long)` | `Object`
`wait(long, int)` | `Object` |  |

## See Also

`Exception`, `IndexOutOfBoundsException`, `RuntimeException`, `Throwable`

StringBuffer |  | System