Uncaught RuntimeException and finally clause: which comes first?

前端 未结 5 653
终归单人心
终归单人心 2021-01-11 10:28

A RuntimeException is thrown in try block without being caught, while the finally clause invokes System.exit().



        
5条回答
  •  醉梦人生
    2021-01-11 11:00

    Finally method always will be executed even in case of return statement in try block ,but in some cases where throwing Errors(Run time memory) in try block there is no guarantee finally block executed completely.

    In your case finally block always executed and exception throws by main method from the JVM since you are not handle the exception.

提交回复
热议问题