The nested for loop

A for loop within a for loop is called a nested for loop. The outer for loop will assign a value from range to i, and the inner for loop will assign a value from range to j, and both values will be printed in the inner for loop:

for (i in 1..3) {
for (j in 1..3) {
println("$i , $j")
}
}

Notice that on each iteration of the outer for loop, the inner for loop will be executed three times. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.166.255