...

/

Iterating over Arrays and Lists

Iterating over Arrays and Lists

We'll cover the following...

You can seamlessly use any of the JDK collection classes and interfaces in Kotlin. Thus, you can use Java’s array and java.util.List in Kotlin as well. Creating instances of these in Kotlin is simpler than in Java, and you can iterate over the values in these collections with greater ease in Kotlin.

Iterate with values

Let’s first create an array of numbers and examine its type:

// iterate.kts
val array = arrayOf(1, 2,
...