Exception handling Exception

There are three types of Exceptions. (1) Error exception (no need to catch) ② Exception type exception (must be caught) ③ RuntimeException type exception (no need to catch)

(2) Exception-type exceptions (checked exceptions) will result in a compile error unless they are caught.

The program crashes due to an error while reading or writing a file, and the file remains open. In that case, the try ~ catch ~ finally statement is effective. try { // Original processing } catch (Exception e) { // Exception handling } finally { // Processing that always works }

Exception propagation Call the sub method from the main method Suppose there is a process to call the subsub method from the sub method. If an Exception occurs in the subsub method Unless caught, it will be fooled by the calling method. This is called exception propagation. However, in the case of Exception type exception, if it is not caught, a compile error will occur, so Exception propagation does not occur, but exception propagation is allowed by making a slow declaration when declaring the method. public static void main method (String str) throws IOException { sub(); }

0922 postscript About specific types of Exception-type exceptions (checked exceptions) -IOException (I / O related exception) -SQLException (DB exception) -ClassNotFoundException (class not found) -InstantiationException (when new class that cannot be instantiated) -InterruptedException (interruption to thread) -NoSuchFieldException (the class does not have the requested field) -NoSuchMethodException (the class does not have the requested method)

Recommended Posts

Exception handling
Exception handling Exception
Java exception handling?
About exception handling
About exception handling
ruby exception handling
Ruby exception handling
[Java] Exception handling
Java exception handling
Java exception handling
Exception handling practice (ArithmeticException)
[Ruby] Exception handling basics
exception
Spring Boot exception handling
Classes that require exception handling
Java's first exception handling (memories)
[Java] Practice of exception handling [Exception]
[Java] About try-catch exception handling
[Ruby] Exception handling in functions
[In-house study session] Java exception handling (2017/04/26)
[Rails] How to write exception handling?
Self-made Exception
Exception handling with a fluid interface
Step-by-step understanding of Java exception handling
[For Java beginners] About exception handling
[Ruby] Exception handling, give back if given
Java (exception handling, threading, collection, file IO)
try-catch-finally exception handling How to use java
Call API [Handling]
[Java] Exception instance
I want to design a structured exception handling
[Swift] Error handling
Questions in java exception handling throw and try-catch
[Java Silver] (Exception handling) About try-catch-finally and try-with-resource statements