The for loop is used with all collection types, and arrays are no exception. We can access every element of the array using the for loop.
Take a look at the following example:
fun arrayAndForloop(){
val strArray = arrayOf("ONE","TWO","THREE","FOUR","FIVE")
for (element in strArray){
println(element)
}
}
On each iteration, the for loop fetches a value from strArray and assigns it to the element. We can use this value in the body of the loop.