• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exception types

 
RajivAwadhesh kumar
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
K Raghavendra
Greenhorn
Posts: 1
 
Campbell Ritchie
Sheriff
Posts: 48381
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20493
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic