0

Why we use finally keyword in exception handling?

11th Feb 2017, 9:20 AM
farwa bajwa
2 Réponses
+ 4
'finally' block is used with a try-catch block and the code in it is always executed, even if the try-catch block has a return statement.
11th Feb 2017, 9:30 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 2
Finally is used in conjunction with a try/catch block. Anything inside of the "finally" clause will be executed regardless of if the code in the 'try' block throws an exception or not. Finally block is used to execute important code such as closing connection, stream etc. It is not always required to use finally block.
11th Feb 2017, 10:39 AM
Nəzər Nəsirzadə
Nəzər Nəsirzadə - avatar