The continue statement is used to skip the remaining steps in the current iteration
and start with the next loop iteration. The control goes from the continue
statement to the step value (increment or decrement), if any.
String[] programmers = {"Adrian", "Paul", "John", "Harry"};
//john is not printed out
for (String name : programmers) {
if (name.equals("John"))
continue;
System.out.println(name);
}
The continue
statement can also make the control of the program shift to the step value (if any) of a named loop:
Outer: // The name of the outermost loop is kept here as 'Outer'
for(int i = 0; i < 5; )
{
for(int j = 0; j < 5; j++)
{
continue Outer;
}
}