public class FinallyDemo2 {
public static void main(String[] args) {
System.out.println(getInt());//结果打印30 所以会执行 用eclipse debug会发现 是在return 之前执行的;
}
public static int getInt() {
int a = 10;
try {
System.out.println(a / 0);
a = 10;
} catch (ArithmeticException e) {
a = 20;
return a;
} finally {
a = 30;
return a;
}
}
} |