Stay organized with collections
Save and categorize content based on your preferences.
StringIndexOutOfBoundsException
open class StringIndexOutOfBoundsException : IndexOutOfBoundsException
Thrown by String
methods to indicate that an index is either negative or greater than the size of the string. For some methods such as the charAt
method, this exception also is thrown when the index is equal to the size of the string.
Summary
Public constructors |
Constructs a StringIndexOutOfBoundsException with no detail message.
|
Constructs a new StringIndexOutOfBoundsException class with an argument indicating the illegal index.
|
Constructs a StringIndexOutOfBoundsException with the specified detail message.
|
Public constructors
StringIndexOutOfBoundsException
StringIndexOutOfBoundsException()
Constructs a StringIndexOutOfBoundsException
with no detail message.
StringIndexOutOfBoundsException
StringIndexOutOfBoundsException(index: Int)
Constructs a new StringIndexOutOfBoundsException
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. |
StringIndexOutOfBoundsException
StringIndexOutOfBoundsException(s: String!)
Constructs a StringIndexOutOfBoundsException
with the specified detail message.
Parameters |
s |
String!: the detail message. |
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,["# StringIndexOutOfBoundsException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nStringIndexOutOfBoundsException\n===============================\n\n```\nopen class StringIndexOutOfBoundsException : IndexOutOfBoundsException\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](/reference/kotlin/java/lang/IndexOutOfBoundsException) ||\n| | | | | ↳ | [java.lang.StringIndexOutOfBoundsException](#) |\n\nThrown by `String` methods to indicate that an index is either negative or greater than the size of the string. For some methods such as the [charAt](/reference/kotlin/java/lang/String#get(kotlin.Int)) method, this exception also is thrown when the index is equal to the size of the string.\n\nSummary\n-------\n\n| Public constructors ||\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [StringIndexOutOfBoundsException](#StringIndexOutOfBoundsException())`()` Constructs a `StringIndexOutOfBoundsException` with no detail message. |\n| [StringIndexOutOfBoundsException](#StringIndexOutOfBoundsException(kotlin.Int))`(`index:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Constructs a new `StringIndexOutOfBoundsException` class with an argument indicating the illegal index. |\n| [StringIndexOutOfBoundsException](#StringIndexOutOfBoundsException(kotlin.String))`(`s:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Constructs a `StringIndexOutOfBoundsException` with the specified detail message. |\n\nPublic constructors\n-------------------\n\n### StringIndexOutOfBoundsException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nStringIndexOutOfBoundsException()\n```\n\nConstructs a `StringIndexOutOfBoundsException` with no detail message. \n\n### StringIndexOutOfBoundsException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nStringIndexOutOfBoundsException(index: Int)\n```\n\nConstructs a new `StringIndexOutOfBoundsException` 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### StringIndexOutOfBoundsException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nStringIndexOutOfBoundsException(s: String!)\n```\n\nConstructs a `StringIndexOutOfBoundsException` 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. |"]]