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?
Asked
Active
Viewed 28 times
0

Clarinetncleats
- 111
- 1
- 9
-
2Read [unchecked exceptions](http://docs.oracle.com/javase/tutorial/essential/exceptions/catchOrDeclare.html) – Reimeus Apr 21 '14 at 00:52
-
Because of a guy named Goodenough. – Hot Licks Apr 21 '14 at 01:17
1 Answers
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