NumberFormatException back to the main() method?
Your premium content subscription is a single payment that gives you:
One of hundreds of answers available with our premium content service.
A: NumberFormatException is an un-checked exception. That means that the compiler will not enforce that your application catches the exception and handles the case. For example, users may enter an invalid number at runtime and the application would throw an exception and crash.
If you want to handle runtime exceptions it is important to handle them in the methods in which they may occur. The callers of such methods cannot be expected to know that they would throw a runtime exception and handle them. Your methods should include validation and handling for specific, anticipated runtime exceptions.
If you want to signal a problem that cannot be handled locally by your method, you should catch the runtime exception and throw a checked exception, as below. This is a typical case for creating your own checked exception type, though rather heavyweight for this simple example.
… full answer hidden
Premium members click below for full answer
How can I throw a NumberFormatException back to the main() method?