wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes catching exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "catching exception" Watch "catching exception" New topic
Author

catching exception

Meg Adal
Ranch Hand

Joined: Mar 12, 2002
Posts: 70
Hi,
I have following code

As method doIt() doesn't throw IOException compiler gives error if I dont comment it
My question is why does it allow to catch only "Exception"??
Is it because Exception class is also a parent of RuntimeException compiler allow us to add try-catch assuming that method can throw runtime exceptions??
Thanks in advance
Megan
[ August 08, 2002: Message edited by: Megan Adal ]
[ August 08, 2002: Message edited by: Megan Adal ]
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Originally posted by Megan Adal:

Is it because Exception class is also a parent of RuntimeException compiler allow us to add try-catch assuming that method can throw runtime exceptions??

That's exactly right Megan!! Because RuntimeException is a subclass of Exception a RuntimeException is a Exception.


Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: catching exception