0
while...loop with continue statement
Error, any solution,please??? public class Program { public static void main(String[] args) { int x = 1; while (x< 10) { if(x == 5) { continue; } System.out.println(x); x += 1; } } } _Output: 1 2 3 4 Time limit exceeded
3 Respostas
+ 6
If you want to use continue then increment x before the continue statement.
if(x == 5)
{
x++;
continue;
}
+ 3
Once x reaches 5, "continue" will forever prevent "x += 1" from being executed again. Eventually, the program is terminated for running too long.
Did you, perhaps, mean to use "break" instead of "continue"?
0
No, I just wanna test the while..loop with the 'continue' statement instead of testing for...loop with it. anyway thanks for helping