Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Java program While loop, input.nextInt()

PROGRAM:


import java.util.Scanner;


public class WhileLoop {
            public static void main(String args[])
            {
            int n;
           
            Scanner input = new Scanner(System.in);
            System.out.println(“Input an integer”);
           
            while((n = input.nextInt())!=0)
            {
                        System.out.println(“You entered” +n);
                        System.out.println(“Input an Integer”);
            }
                        System.out.println(“Out of loop”);
            }

}


OUTPUT:

Input an integer
6
You entered6
Input an Integer
5
You entered5
Input an Integer
0

Out of loop