Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java checked exception

Java has a feature called "checked exceptions". 
That means that there are certain kinds of exceptions, 
namely those that subclass Exception but not RuntimeException, 
such that if a method may throw them, it must list them 
in its throws declaration, say: void readData() throws IOException. 
  IOException is one of those.

Thus, when you are calling a method that lists IOException 
in its throws declaration, you must either list it in your 
own throws declaration or catch it.

The rationale for the presence of 
checked exceptions is that for some kinds of exceptions,
you must not ignore the fact that they may happen, 
because their happening is quite a regular situation, 
not a program error. So, the compiler helps you 
not to forget about the possibility of such an 
exception being raised and requires you to handle it in some way.
Comment

how to handle checked exceptions in java

I would either handle or declare. I Declare using THROWS keyword or handle by
using TRY&CATCH block. If I will use it again I would handle it. If it will
occur only once than I would use THROWS keyword
Comment

PREVIOUS NEXT
Code Example
Java :: kruskal java 
Java :: Java How to use List? 
Java :: better way to check string on null and empty java 
Java :: declare function in java 
Java :: select list of values from db java 
Java :: StackAsMyArrayList 
Java :: constructor 
Java :: app "restart" the home activity (and dismiss all other activities). 
Java :: How to merge two sorted arrays into a single sorted aggregate one? 
Java :: separateur JMenu swing java 
Java :: java easy list 
Java :: how to convert a string of characters to a stream of binary characters binary 
Java :: ArrayList of prime numbers 
Java :: Java Create a BufferedInputStream 
Java :: linked list vs vector 
Java :: interface java 
Java :: jsp check if request parameter exists 
Java :: fullscreen libgdx 
Java :: javafx list view does not update 
Java :: how to merge two arrays in java 
Java :: javafx get actionevent id 
Java :: how to code java??????????? 
Java :: mettre caractère de string en majuscule java 
Java :: csv compare 
Java :: why static variables cannot be serialized in java 
Java :: java linkedlist poll 
Java :: java get number at the end of string 
Java :: java split on { 
Java :: Traversing through java map foreach 
Java :: java static keyword 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =