Iterate Array

suggest change

You can print the array elements with a loop like Java’s enhanced for, but the keyword is in rather than :.

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