In this example, We will Discuss about how to implement continue statement in Java programs.
continue Statement� in Java
In this example, We will Discuss about how to implement continue statement in Java programs. Sometimes we do not need to execute some statements under the loop then we use the continue statement that stops the normal flow of the control and control returns to the loop without executing the statements written after the continue statement.
In the given example we will see how the continue works.
Code:
package com.devmanuals2; public class Continue { public static void main(String[] args) { int j; for (j = 1; j < 5; j++) { if (j == 3) { System.out.println("continue!"); continue; } System.out.println(j); } } }
Output:
1 2 continue! 4 |
[ 0 ] Comments