Java: Proper way to throw and catch an exception to validate input
问题 Im writing a program for homework where I need to validate user input and then create an object and add it to an array list. i have included just what i think is the relevant code, but im a beginner for sure so let me know if there is something else you need to see. I have the user enter a string, then check to see if its a double. if its not a double, i throw an exception that i created try{ price = Double.parseDouble(strPrice); } catch(NumberFormatException nfe){ CDException cde = new