Java Program Of Continue Statement With While Loop

01. Example:

import java.util.Scanner;

class breakStatementWithWhileLoop {
    public static void main(String[] args) {

        int N;
        Scanner input = new Scanner(System.in);

        while (true) {
            System.out.print("Input An Integer: ");
            N = input.nextInt();
            if (N == 0) {
                System.out.println("nYou Entered: 0");
                continue;
            }
            System.out.println("nYou Entered " + N);
        }

    }
}

Output:

Input An Integer: 10
You Entered 10
Input An Integer: 20
You Entered 20
Input An Integer: 30
You Entered 30
Input An Integer: 40
You Entered 40
Input An Integer: 0
You Entered: 0
Input An Integer: 50
You Entered 50
Input An Integer: 60
You Entered 60

Leave a comment