Stay organized with collections
Save and categorize content based on your preferences.
NoSuchElementException
open class NoSuchElementException : RuntimeException
Known Direct Subclasses
InputMismatchException |
Thrown by a Scanner to indicate that the token retrieved does not match the pattern for the expected type, or that the token is out of range for the expected type.
|
|
Thrown by various accessor methods to indicate that the element being requested does not exist.
Summary
Public constructors |
Constructs a NoSuchElementException with null as its error message string.
|
Constructs a NoSuchElementException , saving a reference to the error message string s for later retrieval by the getMessage method.
|
Constructs a NoSuchElementException with the specified detail message and cause.
|
Constructs a NoSuchElementException with the specified cause.
|
Public constructors
NoSuchElementException
NoSuchElementException()
Constructs a NoSuchElementException
with null
as its error message string.
NoSuchElementException
NoSuchElementException(s: String!)
Constructs a NoSuchElementException
, saving a reference to the error message string s
for later retrieval by the getMessage
method.
Parameters |
s |
String!: the detail message. |
NoSuchElementException
NoSuchElementException(
s: String!,
cause: Throwable!)
Constructs a NoSuchElementException
with the specified detail message and cause.
Parameters |
s |
String!: the detail message, or null |
cause |
Throwable!: the cause (which is saved for later retrieval by the getCause() method), or null |
NoSuchElementException
NoSuchElementException(cause: Throwable!)
Constructs a NoSuchElementException
with the specified cause. The detail message is set to (cause == null ? null : cause.toString())
(which typically contains the class and detail message of cause
).
Parameters |
cause |
Throwable!: the cause (which is saved for later retrieval by the getCause() method) |
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# NoSuchElementException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nNoSuchElementException\n======================\n\n```\nopen class NoSuchElementException : 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](../lang/Exception.html#) |||\n| | | ↳ | [java.lang.RuntimeException](../lang/RuntimeException.html#) ||\n| | | | ↳ | [java.util.NoSuchElementException](#) |\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [InputMismatchException](/reference/kotlin/java/util/InputMismatchException) |------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [InputMismatchException](/reference/kotlin/java/util/InputMismatchException) | Thrown by a `Scanner` to indicate that the token retrieved does not match the pattern for the expected type, or that the token is out of range for the expected type. | |\n\nThrown by various accessor methods to indicate that the element being requested does not exist.\n\nSummary\n-------\n\n| Public constructors ||\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [NoSuchElementException](#NoSuchElementException())`()` Constructs a `NoSuchElementException` with `null` as its error message string. |\n| [NoSuchElementException](#NoSuchElementException(kotlin.String))`(`s:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Constructs a `NoSuchElementException`, saving a reference to the error message string `s` for later retrieval by the `getMessage` method. |\n| [NoSuchElementException](#NoSuchElementException(kotlin.String,%20kotlin.Throwable))`(`s:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `cause:` `[Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)!`)` Constructs a `NoSuchElementException` with the specified detail message and cause. |\n| [NoSuchElementException](#NoSuchElementException(kotlin.Throwable))`(`cause:` `[Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)!`)` Constructs a `NoSuchElementException` with the specified cause. |\n\nPublic constructors\n-------------------\n\n### NoSuchElementException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nNoSuchElementException()\n```\n\nConstructs a `NoSuchElementException` with `null` as its error message string. \n\n### NoSuchElementException\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nNoSuchElementException(s: String!)\n```\n\nConstructs a `NoSuchElementException`, saving a reference to the error message string `s` for later retrieval by the `getMessage` method.\n\n| Parameters ||\n|-----|--------------------------------------------------------------------------------------------------------|\n| `s` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: the detail message. |\n\n### NoSuchElementException\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nNoSuchElementException(\n s: String!, \n cause: Throwable!)\n```\n\nConstructs a `NoSuchElementException` with the specified detail message and cause.\n\n| Parameters ||\n|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `s` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: the detail message, or null |\n| `cause` | [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)!: the cause (which is saved for later retrieval by the [getCause()](../lang/Throwable.html#getCause()) method), or null |\n\n### NoSuchElementException\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nNoSuchElementException(cause: Throwable!)\n```\n\nConstructs a `NoSuchElementException` with the specified cause. The detail message is set to `(cause == null ? null : cause.toString())` (which typically contains the class and detail message of `cause`).\n\n| Parameters ||\n|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `cause` | [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)!: the cause (which is saved for later retrieval by the [getCause()](../lang/Throwable.html#getCause()) method) |"]]