I am trying to make a program that receives input from user, which is then used later on in the program. The problem I have is to make an exception. For example, if I only want the user to put in a number between 0 and whatever he previously put in. Here is an example:
Scanner input = new Scanner(System.in);
System.out.println("What length do you want your array to be?");
int length = input.nextInt();
int[] arr = full(length);
print(arr);
System.out.println();
System.out.println("Write a number between (0-"+length+"):");//Its here I want to add an exception.
int number = input.nextInt(); //if the user types in a greater value
check(arr,number); //of "length" or smaller value than 0
//I want the question to repeat itself
//until the criteria is met
You dont have to worry about the "check" or "print methods.