一道关于异常的问题,谢谢
题目是:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1. public class Test {
2. public static String output =““;
3.
4. public static void foo(int i) {
5. try {
6. if(i==1) {
7. throw new Exception();
8. }
9. output += “1”;
10. }
11. catch(Exception e) {
12. output += “2”;
13. return; //若没有return的话则输出134234
14. }
15. finally {
16. output += “3”;
17. }
18. output += “4”;
19. }
20.
21. public static void main(String args[]) {
22. foo(0);
23. foo(1);
24.
25. }
26. }
What is the value of the variable output at line 23?
Answer: 13423.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
当执行foo(1)时,catch语句处理这个异常,在catch中,有个return语句,在这里,return之后的执行情况是怎样的,谢谢!!