forEach
Performs the given action on each entry.
Performs the given operation on each element of this Iterator.
import java.util.*
fun main(args: Array<String>) {
//sampleStart
val iterator = (1..3).iterator()
// skip an element
if (iterator.hasNext()) {
iterator.next()
}
// do something with the rest of elements
iterator.forEach {
println("The element is $it")
}
//sampleEnd
}