0

For example, why is it that ObjectOutputStream.close();, which can throw an IOException, requires error handling (either a try-catch block or a throws declaration) while Integer.parseInt(String s);, which can throw a NumberFormatException, does not?

Clarinetncleats
  • 111
  • 1
  • 9

1 Answers1

0

It's part of the language by design. IOException is a checked exception, and NumberFormatException is an unchecked exception (because it is a subtype of RuntimeException).

Matt Ball
  • 354,903
  • 100
  • 647
  • 710