[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Double Wrapper?



java.lang.NumberFormatException extends java.lang.RuntimeException.
Catching RuntimeExceptions is optional, but sometimes good practice.  When I
use that particular constructor to parse user input, I always enclose it in
a try/catch block.  However, I usually do not enclose division operations in
try/catch blocks, even though they may throw a divide-by-zero
ArithmeticException (another RuntimeException).


Kevin Chipalowsky
http://www.kevinchipalowsky.com



-----Original Message-----
From: D. Michael Nelson [mailto:nelsondm@attbi.com]
Sent: Wednesday, April 17, 2002 5:00 PM
To: Ajug
Subject: Double Wrapper?
Importance: High



Hello,

The class Double constructor is (public Double(String s) throws
NumberFormatException) declared with NumberFormatException (API docs).  Why
do this particular constructor not required to be enclosed in a try/catch
block?

I was under the impression that if a method is declared to throw an
exception the calling method should provide a try/catch or declare itself to
throw the exception.

Thanks in advance,
D. Michael Nelson.