Does a finally block run even if you throw a new Exception?

后端 未结 6 914
梦毁少年i
梦毁少年i 2020-12-22 20:42

In this code will someVar be set even if the catch block is executed and the second Exception is thrown?

public void someFunction() throws Excep         


        
6条回答
  •  南笙
    南笙 (楼主)
    2020-12-22 20:52

    Yes. finally block executes always except the case you call System.exit() because it stops Java VM.

提交回复
热议问题