实践是检验真理的唯一标准,废话不说,上图。
首先是java代码
package zjyang.runprogram;
public class TestReturnFinally {
public static void main(String[] args) {
TestReturnFinally testReturnFinally = new TestReturnFinally();
testReturnFinally.test();
}
private String test(){
try {
System.out.println("try");
return "1";
} catch (Exception e) {
// TODO: handle exception
}
finally{
return "2";
}
}
}
最后,结束。
由此,可以给出答案:try{}中有return语句,紧跟在后的finally会执行,而且是在try{}中的return语句执行完毕之后执行。