A NumberFormatException
is a RuntimeException
.
You don't have to put try
/catch
for runtime exceptions.
From the javadoc of RuntimeException :
RuntimeException is the superclass of those exceptions that can be thrown during the normal operation of the Java Virtual Machine. RuntimeException and its subclasses are unchecked exceptions.
Unchecked exceptions do not need to be declared in a method or constructor's throws clause if they can be thrown by the execution of the method or constructor and propagate outside the method or constructor boundary.
And I seriously doubt any version of Eclipse required a try/catch
for the code you show. You must be confused with another call (maybe a wrapper one declaring the exception, the fact the exception isn't checked doesn't mean you shouldn't, sometimes, explicitly catch it, in fact this one is probably most often explicitly catched).