Tuesday, 24 November 2015

Exception Handling in Java 7 : The Pictorial Way

(Download One Minute Java Mobile app for latest updates)
In this post I am going to introduce you with java 7 modified try-catch block. I am not going to start from scratch, but if some one wants to understand basics of try catch block, do let me know, I will write a separate article. As there are multiple changes to try-catch block I will cover them in series of posts with one change per post.

Change 1 : 
try with multi catch block
As you can see in below image now you can reduce duplicate code by using multi-catch.




















Some rules of try with multi catch block
#Rule 1 :
Multi catch is only for exception with different inheritance hierarchy.






















#Rule 2:
You cannot re-assign value to catch parameter in multi-catch.









#Rule 3:
In Java 7 Exception will not handle all the exceptions, to understand this refer below image



3 comments:

  1. Nice Article with easy explanation...

    ReplyDelete
  2. It is excellent idea to understand.. Thanks

    ReplyDelete
  3. Thanks for post ... easy to understand post

    ReplyDelete