Iterate Array

suggest change

You can print the array elements using the loop same as the Java enhanced loop, but you need to change keyword from : to in.

val asc = Array(5, { i -> (i * i).toString() })
for(s : String in asc){
    println(s);
}

You can also change data type in for loop.

val asc = Array(5, { i -> (i * i).toString() })
for(s in asc){
    println(s);
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents