finally in exception handling

后端 未结 8 1629
甜味超标
甜味超标 2021-01-18 17:08

What exactly does a finally block in exception handling perform?

8条回答
  •  抹茶落季
    2021-01-18 18:01

    finally keyword is used just to make sure that code present in finally block must execute in all circumstances irrespective of exception occurances.

    for eg:

     try{
         }
         catch(Exception e){
         }
          finally{
                 System.out.print("finally executed");
                }
    

    Note: In above case finally will always execute.

提交回复
热议问题