permaculture playing cards*
The moose likes Java in General and the fly likes Use of Checked and Unchecked Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Use of Checked and Unchecked Exception" Watch "Use of Checked and Unchecked Exception" New topic
Author

Use of Checked and Unchecked Exception

Naty wills
Greenhorn

Joined: Sep 20, 2005
Posts: 15
Hi,
I have a query regarding Exceptions in Java, as there are 2 types of exceptions in Java - Checked and Unchecked exceptions, but in other languages viz C++ there is only Unchecked exception. Can someone help me whats the advantage in using Checked and Unchecked exceptions. Why not there is not only Checked exceptions or Unchecked exceptions in Java? Why java supports both Checked and Unchecked exceptions?

Regards
Naty
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
I think as java has the concept of checked exceptions , it gives the developers more flexibility.

In case of checked exceptions , the flow gets a chance to retry some action and make the program continue further.


Rahul Bhattacharjee
LinkedIn - Blog
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Yes instead of leaving the decision to only the runtime environment, developer is also given a choice of how to and what to do further in case of any exception!


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Not really an advanced question. Moving...


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Checked exceptions give the compiler the chance to, well, check to see if they're being handled. The folks who invented Java thought this would requiere developers to acknowledge exceptions and help avoid surprising errors at run time. Many Java users appreciate the compile time help, but some resent the extra coding required to catch or declare throwing checked exceptions.

Bruce Eckel's Thinking In Java (free online) has a good chapter on exceptions that mentions the question whether checked exceptions are good or not.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Naty wills
Greenhorn

Joined: Sep 20, 2005
Posts: 15
Thanks all of you :-)

Regards
~Naty
 
jQuery in Action, 2nd edition
 
subject: Use of Checked and Unchecked Exception
 
Similar Threads
Doubt Reg. Exceptions
Why Checked Exception in Java
Exception
checked & unchecked exceptions...
from khalid- protected void finalize throws throwable...