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

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.
Advertisements

Help to improve or comment as you wish

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

w

Connecting to %s