CSS font stacks & developer FAQs with Web standards

Premium service benefits

Your premium content subscription is a single payment that gives you:

  • Private login to full answers on your chosen subject
  • All future FAQ updates for your topic area
  • Optional email notification of new items
  • Priority attention on follow-up questions
Site navigation below

One of hundreds of answers available with our premium content service.

Part answer, see below for more

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

Click for full answers

Premium members click below for full answer
How can I throw a NumberFormatException back to the main() method?

Home · Web fonts · Font stacks · FAQs · Java · CSS · Javascript · HTML · Site manager