public class Test {
public static void main(String[] args) {
try {
mm();
System.out.println("kdsjf");
} catch (Exception e) {
System.out.println("Catch");
e.printStackTrace();
} finally {
System.out.println("main finally");
}
}
static void mm() throws Exception {
try {
new Exception();
} finally {
System.out.println("finally");
}
}
}
这是结果:
finally
kdsjf
main finally
为什么catch里的没执行啊?

解决方案 »

  1.   

    应该为
    try { 
    throw new Exception(); 
    } finally { 
    System.out.println("finally"); 



    才对
      

  2.   

    try { 
    new Exception(); 
    } finally { 
    System.out.println("finally"); 
    }你只是new了一个异常,但是并没将异常抛出啊。修改为: throw new Exception();
      

  3.   

    mm也要抛出异常
    throw new Exception();