Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch.claude_martin;
- import java.util.Scanner;
- public class SomeClass {
- static Scanner scanner = new Scanner(System.in);
- public static void main(String... args) {
- boolean validInput = false;
- int arrayID = -1;
- do {
- System.out.print("Array ID: ");
- try {
- arrayID = scanner.nextInt();
- validInput = true;
- } catch (Exception e) {
- System.out.println("You must enter an ID (decimal numbers only)\nPlease Try Again !");
- scanner.next();
- }
- } while (!validInput);
- System.out.println("ID has been set to: " + arrayID);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement