本帖最后由 杜成龙 于 2013-6-12 19:05 编辑
- class Verification
- {
- public static String output="";
- public static void foo(int i)
- {
- try
- {
- if(i==1)
- throw new Exception();
- output+="1";
- }
- catch (Exception e)
- {
- output+="2";
- return;
- }
- finally
- {
- output+="3";
- }
- output+="4";
- }
- public static void main(String[] args)
- {
- foo(0);
- System.out.println(output);
- foo(1);
- System.out.println(output);
- }
- }
复制代码 当调用foo(1)时,往里面传的是1,那么就会 throw new Exception(); 但是它下面还有语句,按说编译不应该是失败的吗,它怎么会通过呢?
|