Stay organized with collections
Save and categorize content based on your preferences.
Enumeration
interface Enumeration<E : Any!>
Known Direct Subclasses
StringTokenizer |
The string tokenizer class allows an application to break a string into tokens.
|
|
An object that implements the Enumeration interface generates a series of elements, one at a time. Successive calls to the nextElement
method return successive elements of the series.
For example, to print all elements of a Vector<E>
v:
for (Enumeration<E> e = v.elements(); e.hasMoreElements();)
System.out.println(e.nextElement());
Methods are provided to enumerate through the elements of a vector, the keys of a hashtable, and the values in a hashtable. Enumerations are also used to specify the input streams to a SequenceInputStream
.
Summary
Public methods |
open MutableIterator<E>! |
Returns an Iterator that traverses the remaining elements covered by this enumeration.
|
abstract Boolean |
Tests if this enumeration contains more elements.
|
abstract E |
Returns the next element of this enumeration if this enumeration object has at least one more element to provide.
|
Public methods
asIterator
open fun asIterator(): MutableIterator<E>!
Returns an Iterator
that traverses the remaining elements covered by this enumeration. Traversal is undefined if any methods are called on this enumeration after the call to asIterator
.
Return |
MutableIterator<E>! |
an Iterator representing the remaining elements of this Enumeration |
hasMoreElements
abstract fun hasMoreElements(): Boolean
Tests if this enumeration contains more elements.
Return |
Boolean |
true if and only if this enumeration object contains at least one more element to provide; false otherwise. |
nextElement
abstract fun nextElement(): E
Returns the next element of this enumeration if this enumeration object has at least one more element to provide.
Return |
E |
the next element of this enumeration. |
Exceptions |
java.util.NoSuchElementException |
if no more elements exist. |
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,["# Enumeration\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nEnumeration\n===========\n\n```\ninterface Enumeration\u003cE : Any!\u003e\n```\n\n|----------------------------|\n| [java.util.Enumeration](#) |\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [StringTokenizer](/reference/kotlin/java/util/StringTokenizer) |----------------------------------------------------------------|---------------------------------------------------------------------------------| | [StringTokenizer](/reference/kotlin/java/util/StringTokenizer) | The string tokenizer class allows an application to break a string into tokens. | |\n\nAn object that implements the Enumeration interface generates a series of elements, one at a time. Successive calls to the `nextElement` method return successive elements of the series.\n\nFor example, to print all elements of a `Vector\u003cE\u003e` *v*: \n\n```kotlin\nfor (Enumeration\u003cE\u003e e = v.elements(); e.hasMoreElements();)\n System.out.println(e.nextElement());\n```\n\nMethods are provided to enumerate through the elements of a vector, the keys of a hashtable, and the values in a hashtable. Enumerations are also used to specify the input streams to a `SequenceInputStream`.\n\nSummary\n-------\n\n| Public methods ||\n|----------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [MutableIterator](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-iterator/index.html)\\\u003cE\\\u003e! | [asIterator](#asIterator())`()` Returns an [Iterator](/reference/kotlin/java/util/Iterator) that traverses the remaining elements covered by this enumeration. |\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [hasMoreElements](#hasMoreElements())`()` Tests if this enumeration contains more elements. |\n| abstract E | [nextElement](#nextElement())`()` Returns the next element of this enumeration if this enumeration object has at least one more element to provide. |\n\nPublic methods\n--------------\n\n### asIterator\n\nAdded in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun asIterator(): MutableIterator\u003cE\u003e!\n```\n\nReturns an [Iterator](/reference/kotlin/java/util/Iterator) that traverses the remaining elements covered by this enumeration. Traversal is undefined if any methods are called on this enumeration after the call to `asIterator`.\n\n| Return ||\n|---------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|\n| [MutableIterator](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-iterator/index.html)\u003cE\u003e! | an Iterator representing the remaining elements of this Enumeration |\n\n### hasMoreElements\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun hasMoreElements(): Boolean\n```\n\nTests if this enumeration contains more elements.\n\n| Return ||\n|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true` if and only if this enumeration object contains at least one more element to provide; `false` otherwise. |\n\n### nextElement\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun nextElement(): E\n```\n\nReturns the next element of this enumeration if this enumeration object has at least one more element to provide.\n\n| Return ||\n|---|---------------------------------------|\n| E | the next element of this enumeration. |\n\n| Exceptions ||\n|------------------------------------|----------------------------|\n| `java.util.NoSuchElementException` | if no more elements exist. |"]]