kotlin while loop code example
Example 1: kotlin while
var i = 1
while (i < 5) { // while loop
println(i)
i++
}
var i = 1
do { // do-while loop
println(i)
i++
} while (i < 5)
Example 2: kotlin while loop
while ( isTrue() );
while ( isTrue() ) {
println("while!")
}
do {
println("do while!")
} while (isTrue())
Example 3: kotlin if else condition
if (a > b) {
max = a
} else {
max = b
}
Example 4: while loop kotlin
for (item in collection) print(item)