There is a return statement in the try statement block, but there is no return statement in the catch statement block and finally statement block.
The code is as follows:
publicclassMain{publicstaticvoidmain(String[]args){System.out.println(test1());}publicstaticinttest1(){inti=10;try{System.out.println(try statement);return--i;}catch( Exceptione){System.out.println(catch statement);}finally{System.out.println(finally statement);}return0;}}
The running results are as follows:
try statement finally statement 9
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, execute the return in the try block.