Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What are the below exception Statement can any one explain them?

 
Lal Mothi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Catch (Exception e),
Catch (Error err),

Catch (Throwable t)
 
Jitendra Jha
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are three Catch statements.As we know that java's Exception handling mechanism is derived from the Throwable interface,so the throwable is at the top of exception hierarchy.it has two subclasses,namely error and exception.we can say that both of these are peer classes.
In your statement,Exceptions of type Exception are handled by Exception catch and of type error will be handled by error catch.
Though java allows catch blocks to be organised in a subclass to superclass order,but i doubt that your code will ever need the throwable catch as all exceptions are handled by the first 2 catch blocks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic