wood burning stoves 2.0*
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
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: 19725
    
  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