Kotlin Continue

Chapter: Kotlin Last Updated: 02-03-2018 01:11:06 UTC

Program:

            /* ............... START ............... */
                
fun main(args: Array<String>) {

    for (i in 1..5) {
        println("$i  printed.")
        if (i > 3 && i < 5) {
            continue
        }
        println("$i Exit from continue .")
    }
}

                /* ............... END ............... */
        

Output

1  printed.
1 Exit from continue .
2  printed.
2 Exit from continue .
3  printed.
3 Exit from continue .
4  printed.
5  printed.
5 Exit from continue .

Notes:

  • As like every programming language in Kotlin continue expression skips the current iteration of the enclosing loop, and the control of the program jumps to the end of the loop body.
  • In the above program program if the value of i is greater than three and less than five continue expression is called and control returns back to loop body.
  • Continue statment is used to stop the execution of the body and control goes back to the next iteration.

Tags

Kotlin Continue , Kotlin, Continue Example

Similar Programs Chapter Last Updated
Kotlin Break Statement Kotlin 27-01-2018
Kotlin For Loop Kotlin 30-11-2017
Kotlin Do While Loop Kotlin 19-11-2017
Kotlin While Loop Kotlin 19-11-2017
Kotlin When Statement Kotlin 18-11-2017
Kotlin Nested If Kotlin 18-11-2017
Kotlin If Else If Statement Kotlin 18-11-2017
Kotlin If Statement Kotlin 17-11-2017
Kotlin Print And Println Kotlin 17-11-2017
Kotlin Type Conversion Kotlin 17-11-2017
Kotlin Logical Operators Kotlin 17-11-2017
Kotlin Assignment Operators Kotlin 15-11-2017
Kotlin Arithmetic Operators Kotlin 15-11-2017
Kotlin Data Types Kotlin 12-11-2017
Kotlin Variables Example Kotlin 11-11-2017
Kotlin Comments Example Kotlin 11-11-2017
Kotlin Hello World Kotlin 11-11-2017

1