Continue Statement
The continue statement is used to continue the execution of loop.
In while and do-while loops , a continue statement transfer control to the conditional expression that controls the loop.
In for loop , first control goes to the increment/decrements portion and the goes to the expression.
Simple Program for Continue Statement
package org.modi; public class Test { public static void main(String[] args) { for(int i=0;i<10;i++) { System.out.print( i+" " ); if(i%2==0) continue; System.out.println(""); } } }
OUTPUT
0 1 2 3 4 5 6 7 8 9
From program we can see that when continue statement encountered then first the control goes to the increment/decrements and then goes to expression.
0 comments :
Post a Comment