File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes why sun people developed checked exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why sun people developed checked exceptions" Watch "why sun people developed checked exceptions" New topic

why sun people developed checked exceptions

sravani rendeddula

Joined: Jul 18, 2008
Posts: 1
why sun people developed some uncheched and some checked exceptions without making all exceptions as one type either checked or unchecked?
Rob Spoor

Joined: Oct 27, 2005
Posts: 20273

Because some exceptions should be caught because they are caused by external sources (IOException, SQLException, RemoteException etc), while others can be prevented by enough checks (NullPointerException, IllegalArgumentException, ClassCastException etc). Forcing the latter to be caught would require a try-catch/finally block in each and severy method. Every line of code that involves calling a method can throw a NullPointerException.

If there would be no checked exceptions though, programmers could ignore them, providing no exception handling for these and see their programs crash horribly.

How To Ask Questions How To Answer Questions
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46349
Welcome to JavaRanch
A lots of unchecked exceptions actually represent mistakes in the code which have to be sorted by correcting the code. You need to find the Java Tutorials, which have all sorts of useful information in.
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
The checked vs. unchecked exceptions debate has caused many many religious war. The truth of the matter is that the Java creators took a stand on one side. Whether you believe it's the right side or not (and you're not alone if you don't) is irrelevant. When you code in Java you have to deal with these types of decisions. There are a number of other languages that also took a stand on the other side of the debate. I'm not sure there's a real right or wrong here, as with all things relating to engineering, there are trade offs, and personal preferences.

Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
I agree. Here's the link:
subject: why sun people developed checked exceptions
It's not a secret anymore!