0
Why we use finally keyword in exception handling?
2 Antworten
+ 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.
+ 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.