Is it valid to have finally block without try and catch?

前端 未结 11 1555
遇见更好的自我
遇见更好的自我 2021-02-04 01:32

I am trying to use the finally block without using the try/catch blocks but getting the error in Eclipse.

Can I use the finally block without using the try/catch blocks?

11条回答
  •  不知归路
    2021-02-04 02:22

    • Using only try block is not correct.
    • Try block can be used with only one block from catch or finally block.
    • You can use try block with catch and finally.If you use finally block with try block then catch block become optional.

提交回复
热议问题