Kotlin Loop Break and ContinueLike many other programming languages, Kotlin support
continueduring loops and iterations.
- break function will stop the loop at a specific location.
- continue will skip 1 iteration.
Example Kotlin loop breakIn the below example code will try to loop to index 5 but we have a check at index 3 to break it, the output will be printing indexes until 2.
Example Kotlin loop continueIn the below example code will try to loop to index 5 but we have a check at index 3 to continue and skip it, the output will be printing indexes from 0 to 4 but index 3 will be skipped.
In this page (written and validated by A. Gawali) you learned about Kotlin Loop Break and Continue . What's Next? If you are interested in completing Kotlin tutorial, your next topic will be learning about: Kotlin Array declare access change size find.