September 2019
Intermediate to advanced
462 pages
11h 3m
English
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.
Let’s first create an array of numbers and examine its type:
| | val array = arrayOf(1, 2, 3) |
| | |
| | println(array.javaClass) //class [Ljava.lang.Integer; |
To create an array of values, use the arrayOf() function that belongs to the kotlin package. The functions that belong to the kotlin package may be called without the kotlin prefix—kotlin.arrayOf(), for example—or without any explicit imports. ...
Read now
Unlock full access