wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes exception types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "exception types" Watch "exception types" New topic
Author

exception types

RajivAwadhesh kumar
Greenhorn

Joined: May 20, 2011
Posts: 24
Why java has 2 types of ecxeptions(checked and unchecked)? why should we not treat Unchecked exceptions e.g NullPointerException like
checked exceptions.. I mean what if we catch or declare a method as throwing a NullPointerException?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

Unchecked exceptions are typically generated because of sloppy programming. The code should be handling these cases where unchecked exceptions might arise. Propagating it so that someone else can handle it is a bad idea.
This is a good read http://download.oracle.com/javase/tutorial/essential/exceptions/runtime.html


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
K Raghavendra
Greenhorn

Joined: Oct 19, 2011
Posts: 1
Please read this link

http://tutorials.jenkov.com/java-exception-handling/checked-or-unchecked-exceptions.html
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38481
    
  23
Welcome to the Ranch K Raghavendra

It is often worthwhile going through the other fora RajivAwadhesh kumar; you would have found, for example, this.
Gaurav Raje
Ranch Hand

Joined: Jul 23, 2010
Posts: 136
This is quite a debated topic
http://www.ibm.com/developerworks/java/library/j-jtp05254/index.html

In fact Microsoft found it useful to get rid of checked exceptions in C#... google up for their reasons as to why they felt it created problems
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19680
    
  18

Which will only lead to more unexpected errors for the user when programmers forget to catch these exceptions. The default "stack trace" dialog can be quite intimidating for most users.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: exception types