This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes double.parseDouble()  - Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "double.parseDouble()  - Exception" Watch "double.parseDouble()  - Exception" New topic
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
Rancher

Joined: May 31, 2011
Posts: 1776
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: 44433
    
  33
And welcome to the Ranch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: double.parseDouble() - Exception
 
It's not a secret anymore!