Simple While Loop
The below command line program demonstrates how to create a simple loop that repeats until a user inputs a specific value.
Main.java
package ceccs;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int userInput = 0;
while (userInput != 0) {
System.out.println("Input a number that's not zero:");
userInput = scan.nextInt();
}
System.out.println("You monster! I Quit!");
}
}