java tutorial

When to use Checked and Unchecked Exception in Java

Checked and unchecked Exception are two different types of Exception in java. both are similar in functionality and you can do all things with checked exception which are possible with unchecked exception. though there are some subtle differences like for unchecked exception you don’t
need to add explicit try catch block which pollute code in case of checked Exception.

Key point is how do you decide whether business Exception should be checked or unchecked.like here InsufficientFundsException can be both, share your thought on that, my go is if you have an alternative when an operation failed or chances of failing an operation is more than consider declaring it as checked Exception.

Both throw and throws can be used in conjuction with checked and unchecked Exception

 

read ful article at: http://javarevisited.blogspot.com/2011/12/checked-vs-unchecked-exception-in-java.html

Advertisements

Leave a Reply

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s