Tuesday, 29 December 2015

Difference between 'final' and 'finally'?



final:

final is a keyword. The variable decleared as final should be
initialized only once and cannot be changed. Java classes
declared as final cannot be extended. Methods declared as final
cannot be overridden.

finally:

finally is a block. The finally block always executes when the
try block exits. This ensures that the finally block is executed
even if an unexpected exception occurs.

No comments:

Post a Comment