File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

catching exception

 
Meg Adal
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic