This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Exceptions query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exceptions query" Watch "Exceptions query" New topic
Author

Exceptions query

Ajay Kumar Rana
Greenhorn

Joined: Feb 27, 2008
Posts: 13
Is NumberFormatException subclass of FileNotFoundException ? where can i get the information that one exception class is subclass of another or not.
Huzefa Zohaib
Ranch Hand

Joined: Nov 21, 2001
Posts: 40
By observing the class hierarchy in API, you can get the information that class is of what type !!!

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/NumberFormatException.html


However NumberFormatException in not subclass of FileNotFoundException !!!

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
java.lang.IllegalArgumentException
java.lang.NumberFormatException
[ March 12, 2008: Message edited by: Huzefa Zohaib ]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

Why would NumberFormatException be a subclass of FileNotFoundException in the first place?

I mean, NumberFormatException indicates that a string cannot be formatted into a number. FileNotFoundException indicates a file cannot be found. How are these two events related? They aren't!

On the other hand, FileNotFoundException is a subclass of IOException because it is an exception caused by some form of disk I/O. Similarly, NumberFormatException is a subclass IllegalArgumentException because the string that is formatted is illegal for the formatting methods.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exceptions query