定理:
finally 語句是在try的return 語句執行以後,return 返回以前執行。java
證實:
bash
public class Client { public static void main(String[] args) { int test = test(); System.out.println("resutl:"+test); } private static int test1(){ System.out.println(" return exe..."); return 1; } private static int test(){ try { System.out.println("try"); return test1(); }finally { System.out.println("finallly"); } } }
結果:code
try return exe... finallly resutl:1