Exceptions are caused by an error in executing the function, and the function is a layer of nested layers called to form the call stack. As a result, an error occurs in one of the multi-layered nested functions, and the rest will fail to execute. The exception tracking stack is formed when all these functions output exception information.
At the very beginning of the code where the exception occurred, called the exception throw point. The remainder of the exception that occurs because of a function exception is traced back to the bottom of the call stack. Such behavior, called, is abnormal bubbling.
The basic syntax of exception handling try-catch-finally, there are the following points to note:
1.try, catch, finally in the respective local variables can only be used locally, each other can not be interoperable.
2. Each catch block is used to handle an exception, and the run order is matched from top to bottom. If a parent-child relationship exists between the catch blocks in the same try, it should be placed on top and the parent class behind.
The throws function declares that if the code inside a method throws a check exception (checked exception), and the method does not completely handle the exception, then JAVSC requires that the throws keyword be written behind the method name, or the compilation does not pass.
Throws only throws an exception type and does not handle it, throwing an exception for the caller to handle.
Finally block: Regardless of whether there is an exception, as long as the corresponding try executes, he will execute. In programming, develop a good habit of opening a resource in try and closing the resource in finally. It is most appropriate to write only the cleanup resources in finally, and do not deal with any problems in this area. The return statement, preferably written on the last side of the function, is not written in try-catch-finally.
Well, my understanding of the anomaly, is so far, will know more, experience is slowly accumulated, come on
Exception handling mechanism for Java (bottom)