How to parse multiple integers

Viewed 756

So I want to parse multiple integers by dividing them by , or space. Let's say user is only allowed to enter 4 numbers max. So how do I make multiple check if user enters for instance ( 1 2 4 3 ) or (1 2 3)? Because it would be not smart to make check for every different choice made. ( currently I'm only checking 4 choices 1, 2 3 or 4) since he should not be able to make a choice of more than 4

String choose = JOptionPane.showInputDialog(null, ("Some text"));
int userchoice = Integer.parseInt(choose);
if(userchoice ==1){
    //Do something
}
1 Answers
Related