v1.8.10
  • Solutions
    • Multiplatform Mobile
    • Multiplatform for other platforms
    • Server-side
    • Web frontend
    • Data science
    • Android
  • Docs
  • Community
  • Teach
  • Play
    • Playground
    • Hands-on
    • Examples
    • Koans
← Docs
kotlin-stdlib / kotlin.collections / java.util.Enumeration / iterator

iterator

JVM
1.0
operator fun <T> Enumeration<T>.iterator(): Iterator<T>
(source)

Creates an Iterator for an java.util.Enumeration, allowing to use it in for loops.

import java.util.*

fun main(args: Array<String>) {
//sampleStart
val vector = Vector<String>().apply {
    add("RED")
    add("GREEN")
    add("BLUE")
}

// iterator() extension is called here
for (e in vector.elements()) {
    println("The element is $e")
}
//sampleEnd
}
Stay in touch:
  • Contributing to Kotlin
  • Releases
  • Press Kit
  • Security
  • Blog
  • Issue Tracker
  • Brand assets
  • Careers
Kotlin™ is protected under the Kotlin Foundation and licensed under the Apache 2 license.
Supported and developed by JetBrains