终于总是被召唤?

Pau*_*icz 6 java

可能重复:
在Java中,最终会返回特朗普吗?

这个函数返回什么?

public int wasExceptionThrown() {
   try {
     if(1==1)
        throw new RuntimeException();
     return 1;
   } catch(Exception e) {
     return 2;
   } finally {
     return 3;
   }
   return 0;
}
Run Code Online (Sandbox Code Playgroud)

Pet*_*rey 7

如果调用System.exit(0);finally不会调用块,因为线程立即关闭.在所有其他情况下finally,当块退出时调用(假设它)