8
捕获和最终返回语句的行为
请参见以下代码,并解释输出行为。 public class MyFinalTest { public int doMethod(){ try{ throw new Exception(); } catch(Exception ex){ return 5; } finally{ return 10; } } public static void main(String[] args) { MyFinalTest testEx = new MyFinalTest(); int rVal = testEx.doMethod(); System.out.println("The return Val : "+rVal); } } 结果是返回Val:10。 Eclipse显示警告:finally block does not …