I am new to programming and need help creating an error message for one of my programs. My question is how do I make java show an error if the user were to enter letters instead of a number and how can I make a loop to keep asking for the input and show the error as long as the input is not a number.
The following is only part of my code and the only part I want to show an error message for incorrect input.
String YearString = JOptionPane.showInputDialog(null, "Please enter a year, for example 1700:", "Finding Easter", JOptionPane.QUESTION_MESSAGE); int YEAR = Integer.parseInt(YearString);
Thanks in advance to all who helped!