(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
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
Nice Article with easy explanation...
ReplyDeleteIt is excellent idea to understand.. Thanks
ReplyDeleteThanks for post ... easy to understand post
ReplyDelete