I'm trying to follow the "Head First Kotlin" book exercises and I wrote the following code:
val numList = arrayOf(1,2,3);
var x = 0;
fun main() {
while (x < 3) {
println("Item $x is $numList[x]");
x += 1;
}
}
Kotlin printed:
Item 0 is [Ljava.lang.Integer;@30f39991[x]
Item 1 is [Ljava.lang.Integer;@30f39991[x]
Item 2 is [Ljava.lang.Integer;@30f39991[x]
But I expected to be:
Item 0 is 1
Item 1 is 2
Item 3 is 3
What am I doing wrong? Any help would be greatly appreciated!