continue statement forces an early iteration of a loop.
while and do-while loops, a continue statement causes control to be transferred to the conditional
expression that controls the loop. for loop, control goes first to the iteration portion of the for statement and then to the conditional expression.The following code shows how to use a continue statement.
public class Main {
public static void main(String[] argv) {
for (int i = 0; i < 10; i++) {
System.out.print(i + " ");
if (i % 2 == 0)
continue;
System.out.println("");
}
}
}
The code above generates the following result.
0 1
2 3
4 5
6 7
8 9 java2s.com | | Contact Us | Privacy Policy |
| Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
| All other trademarks are property of their respective owners. |