Compiler Designing W10L1803

Java Exceptions

  • Handling something unexpectable gracefully.
class Foo {
     public static void main(String[] args){
          try{X();} catch(Exception e){System.out.println("Error");} 
     public void X() throws MyException {
           throw new MyException();

Exception expressions:


gif (1)

When try block is executing, it goes all in the stack and when throw is to be executed, all the contents of the try block has to be popped.

  • An uncaught exception during object finalization(cleans object) can not be handled.

Help to improve or comment as you wish

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s