Java continue Statement in do-while Loop Example

This Java example demonstrates how to use a continue Statement inside the do-while loop in Java with an example.

Java continue Statement in do-while Loop Example

package net.javaguides.corejava.controlstatements.loops;

public class ContinueExample {
    public static void main(String args[]) {
        int j = 0;
        do {
            if (j == 7) {
                j++;
                continue;
            }
            System.out.print(j + " ");
            j++;
        } while (j < 10);

    }
}
Output:
0 1 2 3 4 5 6 8 9 
Note that we have skipped iteration when j==7.


Comments