There are return statements in the try statement block and finally statement block, but there is no return statement in the catch statement block.
The code is as follows:
publicclassMain{publicstaticvoidmain(String[]args){System.out.println(test2());}publicstaticinttest2(){inti=10;try{System.out.println(try statement);return--i;}catch( Exceptione){System.out.println(catch statement);}finally{System.out.println(finally statement);return--i;}}}
The running results are as follows:
try statement finally statement 8
Execution order:
1. First execute the statement in the try block, including the expression operation in the return statement, but do not return.
2. Execute all the code in the finally statement block.
3. Finally, I found that there is a return statement in the finally statement block, and return from here.