Stay organized with collections
Save and categorize content based on your preferences.
IndexOutOfBoundsException
open class IndexOutOfBoundsException : RuntimeException
Thrown to indicate that an index of some sort (such as to an array, to a string, or to a vector) is out of range.
Applications can subclass this class to indicate similar exceptions.
Summary
Public constructors |
Constructs an IndexOutOfBoundsException with no detail message.
|
Constructs a new IndexOutOfBoundsException class with an argument indicating the illegal index.
|
Constructs an IndexOutOfBoundsException with the specified detail message.
|
Constructs a new IndexOutOfBoundsException class with an argument indicating the illegal index.
|
Public constructors
IndexOutOfBoundsException
IndexOutOfBoundsException()
Constructs an IndexOutOfBoundsException
with no detail message.
IndexOutOfBoundsException
IndexOutOfBoundsException(index: Int)
Constructs a new IndexOutOfBoundsException
class with an argument indicating the illegal index.
The index is included in this exception's detail message. The exact presentation format of the detail message is unspecified.
Parameters |
index |
Int: the illegal index. |
IndexOutOfBoundsException
IndexOutOfBoundsException(s: String!)
Constructs an IndexOutOfBoundsException
with the specified detail message.
Parameters |
s |
String!: the detail message |
IndexOutOfBoundsException
IndexOutOfBoundsException(index: Long)
Constructs a new IndexOutOfBoundsException
class with an argument indicating the illegal index.
The index is included in this exception's detail message. The exact presentation format of the detail message is unspecified.
Parameters |
index |
Long: the illegal index. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# IndexOutOfBoundsException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nIndexOutOfBoundsException\n=========================\n\n```\nopen class IndexOutOfBoundsException : RuntimeException\n```\n\n|---|---|---|---|------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||||\n| ↳ | [kotlin.Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html) ||||\n| | ↳ | [java.lang.Exception](/reference/kotlin/java/lang/Exception) |||\n| | | ↳ | [java.lang.RuntimeException](/reference/kotlin/java/lang/RuntimeException) ||\n| | | | ↳ | [java.lang.IndexOutOfBoundsException](#) |\n\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [ArrayIndexOutOfBoundsException](/reference/kotlin/java/lang/ArrayIndexOutOfBoundsException), [CursorIndexOutOfBoundsException](../../android/database/CursorIndexOutOfBoundsException.html#), [StringIndexOutOfBoundsException](/reference/kotlin/java/lang/StringIndexOutOfBoundsException) |-------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------| | [ArrayIndexOutOfBoundsException](/reference/kotlin/java/lang/ArrayIndexOutOfBoundsException) | Thrown to indicate that an array has been accessed with an illegal index. | | [CursorIndexOutOfBoundsException](../../android/database/CursorIndexOutOfBoundsException.html#) | An exception indicating that a cursor is out of bounds. | | [StringIndexOutOfBoundsException](/reference/kotlin/java/lang/StringIndexOutOfBoundsException) | Thrown by `String` methods to indicate that an index is either negative or greater than the size of the string. | |\n\nThrown to indicate that an index of some sort (such as to an array, to a string, or to a vector) is out of range.\n\nApplications can subclass this class to indicate similar exceptions.\n\nSummary\n-------\n\n| Public constructors ||\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [IndexOutOfBoundsException](#IndexOutOfBoundsException())`()` Constructs an `IndexOutOfBoundsException` with no detail message. |\n| [IndexOutOfBoundsException](#IndexOutOfBoundsException(kotlin.Int))`(`index:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Constructs a new `IndexOutOfBoundsException` class with an argument indicating the illegal index. |\n| [IndexOutOfBoundsException](#IndexOutOfBoundsException(kotlin.String))`(`s:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Constructs an `IndexOutOfBoundsException` with the specified detail message. |\n| [IndexOutOfBoundsException](#IndexOutOfBoundsException(kotlin.Long))`(`index:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`)` Constructs a new `IndexOutOfBoundsException` class with an argument indicating the illegal index. |\n\nPublic constructors\n-------------------\n\n### IndexOutOfBoundsException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nIndexOutOfBoundsException()\n```\n\nConstructs an `IndexOutOfBoundsException` with no detail message. \n\n### IndexOutOfBoundsException\n\nAdded in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nIndexOutOfBoundsException(index: Int)\n```\n\nConstructs a new `IndexOutOfBoundsException` class with an argument indicating the illegal index.\n\nThe index is included in this exception's detail message. The exact presentation format of the detail message is unspecified.\n\n| Parameters ||\n|---------|------------------------------------------------------------------------------------------------|\n| `index` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the illegal index. |\n\n### IndexOutOfBoundsException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nIndexOutOfBoundsException(s: String!)\n```\n\nConstructs an `IndexOutOfBoundsException` with the specified detail message.\n\n| Parameters ||\n|-----|-------------------------------------------------------------------------------------------------------|\n| `s` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: the detail message |\n\n### IndexOutOfBoundsException\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nIndexOutOfBoundsException(index: Long)\n```\n\nConstructs a new `IndexOutOfBoundsException` class with an argument indicating the illegal index.\n\nThe index is included in this exception's detail message. The exact presentation format of the detail message is unspecified.\n\n| Parameters ||\n|---------|--------------------------------------------------------------------------------------------------|\n| `index` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): the illegal index. |"]]