Tsallaka zuwa abun ciki
Justice Tech School

Kotlin Break and Continue

break exits a loop and continue skips to the next round. Labels such as outer@ let you break from an outer loop.

Example
for (i in 1..5) {
    if (i == 2) continue
    if (i == 4) break
    print("$i ")
}
println()
outer@ for (a in 1..3) for (b in 1..3) { if (b == 2) continue@outer; print("$a$b ") }

Exercise

Skip to the next round.

if (x) 

Quiz Test

What does break do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.