July 2018
Intermediate to advanced
400 pages
12h 14m
English
If you have worked with Java, you know that it supports primitive definitions of arrays – different from the reference types like List and Set that you worked with in this chapter. Kotlin also includes a number of reference types, called Arrays, that compile down to Java primitive arrays. Arrays are included primarily to support interoperability between Kotlin and Java.
Suppose you had a Java method that you wanted to call from Kotlin that looked like this:
static void displayPlayerAges(int[] playerAges) {
for(int i = 0; i < ages.length; i++) {
System.out.println("age: " + ages[i]);
}
}
Notice that the parameter expected by displayPlayerAges is int[] playerAges, a Java primitive array of int ...
Read now
Unlock full access