aspose file tools
The moose likes Java in General and the fly likes checked exception Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "checked exception" Watch "checked exception" New topic
Author

checked exception

Eshwin Sukhdeve
Ranch Hand

Joined: Mar 15, 2012
Posts: 78
we use unchecked exception so that we can handled runtime exception.for exmaple I am storing values in array.if it exceeds then it
will give the ArrayIndexOutOfBoundException .but my doubt is why checked exception must handled.means is it internally throwing some excpetion.
John Jai
Bartender

Joined: May 31, 2011
Posts: 1778
Checked Exceptions are present so that the programmer have to mandatory handle that in her code.

JLS suggests why there are checked Exceptions - Checked Exceptions
This compile-time checking for the presence of exception handlers is designed to reduce the number of exceptions which are not properly handled.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Checked exceptions are for things which can occur normally during the execution of a program that a programmer can't prevent, but may be able to handle, such as a network connection failing or an expected file not being present. The compiler forces us to acknowledge them so that we don't accidentally miss an error condition that we could have done something about, and only certain, known checked exceptions can occur at any given point in our code, so it is reasonable to enumerate them individually.

Unchecked exceptions are for two kinds of conditions that we shouldn't usually handle at runtime: 1) Bugs in our code (RuntimeException and its descendants, for the most part), and 2) Internal problems in the JVM (Error and its descendants). We generally shouldn't handle #1 at runtime because the can be prevented entirely by fixing the bugs in our code. For instance, we don't usually catch NullPointerException. Instead, we fix our code so it doesn't happen in the first place. And #2 is something we usually can't do anything about. By the time an Error has been thrown, usually the JVM or our app has gone off the rails and probably cannot recover. Also, since any number of unchecked exceptions can happen at any given point in our code, there's no point in trying to explicitly list them all.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: checked exception
 
Similar Threads
exceptions
why we have checked & unchecked exception
chained exception
checked Exception