aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why sun people developed checked exceptions" Watch "why sun people developed checked exceptions" New topic
Author

why sun people developed checked exceptions

sravani rendeddula
Greenhorn

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
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
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: http://aspose.com/file-tools
 
subject: why sun people developed checked exceptions