There are several exceptions in Java:
1) Error:java internal Error during operation;
2) Exception: Exceptions that should be caught in the program.
RuntimeException: errors caused by programming;
IOException: Error generated by input and output.
Method of exception handling:
1) Try-catch
A try statement block can have only one, and a catch can have multiple, and a catch must follow the try statement with no other code in between. If there are multiple catch statements, the catch statement that captures the parent exception must be placed behind it, otherwise it will catch all of its subclass exceptions, leaving the subclass exception catch statement to never execute.
2) finally
When an exception occurs, the program jumps out of the currently running statement block, finds the exception capture statement block, and then jumps back to the program to execute the catch statement.
However, sometimes after an exception, some statements must be executed, this time can be used finally. It specifies that the block of statements be executed anyway. There can be only one finally statement block in a try-catch. Also, in general, the finally statement block is placed after the last catch statement block.
3) throws
Throws an exception in the method, the handling of the exception is left to the caller of the method, an exception is thrown in the method definition, and when the method is called, the method call statement must be placed in the Try-catch statement block and the corresponding exception is caught in the catch.
A preliminary study of exception handling in Java