I'm asking my user to input via regex format "ABC-1234" otherwise an IllegalArgumentException
is thrown. I would like to keep asking for the correct input (I'm thinking while or do while with a boolean variable set to false while input is incorrect...) how would I do that with a try / catch?
Here's what I have thus far. Thanks!
try {
Scanner in = new Scanner (System.in);
System.out.println("Please enter id: ");
String id = in.nextLine();
Inventory i1 = new Inventory (id, "sally", 14, 2, 2);
System.out.println(i1);
} catch (Exception ex) {
System.out.println(ex.getMessage());
}