Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте continue Statement in Kotlin | Advanced Loop Techniques
Kotlin Loops

bookcontinue Statement in Kotlin

Свайпніть щоб показати меню

The continue statement is a powerful tool in Kotlin loops. When you use continue inside a loop, it immediately ends the current iteration and jumps to the next one. This means that any code after the continue statement within the loop block is skipped for that iteration. You often use continue when you want to ignore certain cases or values while looping, but still continue processing the rest.

Main.kt

Main.kt

copy

In the example above, the loop goes through numbers from 1 to 10. When the current number i is even (i % 2 == 0), the continue statement is executed. This skips the rest of the code in the loop for that iteration, so println(i) is not called for even numbers. As a result, only odd numbers are printed. Using continue in this way changes the normal flow of the loop by allowing you to skip processing for certain values without stopping the loop entirely.

question mark

What happens when the continue statement is executed in a loop?

Виберіть правильну відповідь

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 3

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Секція 3. Розділ 3
some-alt