In Java try catch finally, there is return in try, is finally executed?

## Execution, and finally execution is earlier than return in try

in conclusion:

1. No matter there is an exception, the code in the finally block will be executed;
2. When there is a return in try and catch, finally will still be executed;

. 3, is finally (and does not return a value arithmetic operation expression executed after return later time, but the first holding value to return
save up, how to code tube finally, the return value is not Will change, still the value saved before), so the return value of the function is
determined before finally execution;

4. It is best not to include return in the finally, otherwise the program will exit early, and the return value is not the return saved in try or catch value.

Guess you like

Origin blog.csdn.net/m0_51684972/article/details/109175146