What I am trying to do is get a list of numbers from the user, the numbers must be in the 1 - 9 range so they will all be single digits. I do not know ahead of time how many numbers there will be, except that it will be at least 1 and no more than 4.
I was using the following code to get them one at a time:
I could put this in a loop until they enter something out of range but I don't really like that idea. I would to have something like this:Code:Scanner in = new Scanner(System.in); System.out.println("Enter a number: "); int yourInt = in.nextInt();
Enter some numbers: 2 5 1
and end up with an int array x such that
x[0] = 2;
x[1] = 5;
x[2] = 1;
And I actually don't care about the order.
It is just a simple console based application for my own use so at this point I am not worrying about the exception handling.
Any thoughts or ideas?
Deroga.


Reply With Quote


Bookmarks