| Author |
double.parseDouble() - Exception
|
Niran Raj
Greenhorn
Joined: Sep 24, 2011
Posts: 1
|
|
try {
double val = double.parseDouble("fsd");
} catch(IllegalArgumentException ex) {
}
Is it good to catch parent exception(IllegalArgumentException) of NumberFormatException ?
|
 |
John Jai
Bartender
Joined: May 31, 2011
Posts: 1778
|
|
|
In my opinion catching specific exception is better. It enables you to do different things in the catch block... like assigning a default value and move on during a number format exception or exit the method and throw exception when you get an IllegalArgument exception
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
And welcome to the Ranch
|
 |
 |
|
|
subject: double.parseDouble() - Exception
|
|
|