问运行结果多少?public class TestException {
public int get() {
try {
return 1;
} catch (Exception e) {
e.printStackTrace();
} finally { // finally里的都会执行,在try里的return
// 1后还会执行吗?答案经检测:是的。2把1给覆盖了。get()最终返回的是2!
return 2;
}
}
public static void main(String[] args) {
TestException te = new TestException();
System.out.println(te.get());
}
}
结果运行下是2!