Execution order of Try-catch blocks
Put the code that might appear to be the exception in the try block, and if an exception occurs, execute the statement in the catch block without executing the statement that follows the try block, to catch and handle the exception.
If you have multiple catch blocks, you need to be aware of the order of the catch blocks, which must be "from subclass to parent class." If one of the catch and exception types is the same, the rest of the catch block is not executed.
Execution order of try-catch-finally blocks
The contents of the finally block are "always executed". Regardless of whether an exception occurred.
If a return statement is in both the try block and finally block, the return statement in finally is always executed.
Declaring and Throwing exceptions
Declare exceptions using the throws keyword followed by the exception type. Throws must be followed by the method parameter list, cannot be used alone, and can declare multiple exceptions.
Throws an exception using the Throw keyword.
Exception chain
The exception chain in Java is that when Try-catch handles an exception, it does not process in the catch, just throws the exception information and the exception object again, and captures and processes the previous layer.
Exceptions in Java