/* */ Click to Join Live Class with Shankar sir Call 9798158723

Continue statement


Continue statement is similar as a break statement that is used inside a loop to repeat the next iteration of the loop.the control was transfers from the next iteration and the rest of the code don’t execute for the iteration.It uses along with the if statement in loops. when the condition was give returns true, then the continue statement transfers the control of the loop immediately to the next iteration.The continues statement is useful whenever use want to skip the iteration based on conditions.


Syntex :-

While(condition)
{
action -1
continue;
action n;
}

Q.) W.A.P of to Print 1 to 6 ?
    public class ContinueExample {

public static void main(String args[]){
 for (int j=0; j<=6; j++)
 {
        if (j==4)
        {
       continue;
    }

        System.out.print(j+" ");
 }
}
}
Output
0
1
2
3
5
6