Posts

Showing posts with the label exception handling in java with example

Exception Handling in java with example

Image
Exception occurs only at run-time but some exceptions are detected at compile-time and some others at run-time. The exception that are checked at compilation time by the Java Compiler are called 'Checked exceptions' while the exceptions that are checked by the JVM are called 'Unchecked Exceptions' .        Unchecked exceptions and errors are considered as unrecoverable and the programmer cannot do anything when they occur. The programmer can write a Java program with unchecked exceptions and errors and can compile the program. He can see their effect only when he runs the program. 1 public static void main ( String [] args ) throws IOException        Here, IOException is an example for checked exception. So, we threw it out of main() method without handling it. This is done by throws clause written after main() method in the above statement.          ...