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?
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