Java Exceptions Practice 56.2 Category Handling Fails Test Case 4
I am having trouble with Java Exceptions Practice 56.2 Category Handling It is supposed to catch exceptions and output: "Wrong Option" I have tried a generic catch (exception e), I have also tried to catch NoSuchElementException instead of catching InputMismatchException I also tried just letting it throw an InputMismatchException on a non-integer input. I haven't been able to think of any test cases I didn't try in my IDE. import java.util.InputMismatchException; import java.util.Scanner; //fails test case 4 public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String[] categories = {"PCs", "Notebooks", "Tablets", "Phones", "Accessories"}; try { int choice = scanner.nextInt(); System.out.println(categories[choice]); } catch(ArrayIndexOutOfBoundsException | InputMismatchException e) { System.out.println("Wrong Option"); } } }