As soon as an exception falls into this code, the menuSystem method menuSystem , but as soon as I go to enter the number, the program closes and the message "Build is successful" is displayed. Is there a way to return to the while loop after an exception occurs?
public static void main(String[] args) { final UnitResults myUnit = new UnitResults(10, "Java"); int option = menuSystem(); try { while (option != 0) { final Scanner keyb = new Scanner(System.in); System.out.println(""); switch (option) { } } } catch (Exception InputMismachException) { System.out.println("\nPlease Enter a Valid Number\n"); option = menuSystem(); } }
Bunion
source share