kotlin for llop code example
Example 1: for loop kotlin
for (x in 0..10) println(x)
Example 2: kotlin loop
var bubbles = 0
while (bubbles < 50) {
bubbles++
}
println("$bubbles bubbles in the water\n")
do {
bubbles--
} while (bubbles > 50)
println("$bubbles bubbles in the water\n")
repeat(2) {
println("A fish is swimming")
}
-> 50 bubbles in the water
49 bubbles in the water
A fish is swimmingA fish is swimming