Exception This exception is divided into two major classes of runtime exceptions and non-runtime exceptions (compilation exceptions). These exceptions should be handled as much as possible in the program.
Run-time Exceptions: both the RuntimeException class and its subclass exceptions, such as nullpointerexception (null pointer exception), indexoutofboundsexception (subscript out-of-bounds exception), etc. These exceptions are not checked for exceptions, the program can choose to capture the processing, or it can not be processed. These exceptions are usually caused by a program logic error, and the program should avoid this kind of exception as much as possible from a logical point of view.
A run-time exception is characterized by the Java compiler not checking it, that is, when such an exception can occur in a program, even if it is not captured with the Try-catch statement, it is not thrown with the throws clause declaration, and it is compiled.
Non-runtime exception (compile exception): is an exception other than RuntimeException, and the type belongs to the exception class and its subclasses. From the point of view of the program syntax is the exception that must be handled, and if not handled, the program cannot be compiled through. such as IOException, SqlException, and user-defined exception exceptions, generally do not customize check exceptions.
Java exception mechanism