Why do we use finally blocks?

前端 未结 11 2218
甜味超标
甜味超标 2020-11-27 11:43

As far as I can tell, both of the following code snippets will serve the same purpose. Why have finally blocks at all?

Code A:

try { /*          


        
11条回答
  •  感情败类
    2020-11-27 12:33

    There may be times when you want to execute a piece of code no matter what. Whether an exception is thrown or not. Then one uses finally.

提交回复
热议问题