The do while loop  

do while loop executes a block of code at least once, and then repeatedly executes the block (or not) depending on a given condition at the end of the block. This is a minor variation of the while loop. In do while, the body executes before the condition is verified, therefore executing the code block at least once:

fun main(args: Array<String>) {
println("Do While loop")
var j = 1
do {
println(j)
j++
} while( j < 5 )
}

In this example, variable j is initialized with value 1, the do block prints the value of j and increments it, while block verifies the condition. The loop will continues until the value of j is less than 5

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

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