Hi friends
I want to know what is different among final, finally and finalize() in java.
Thank you.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted May 27, 2012, 4:36 AM
final – This is a key word / access modifier to define constants.
finally – The finally block always used in conjunction with try and catch blocks, except that, if try block uses System.exit(0) call. It is ensured that in event of an unexpected error / exception, the finally block performs the execution. Not only for exception handling, finally also even utilized for cleaning up the code, such as returning values, continue or break statement usage, closing streams etc. It is a good programming practice to use cleaning up the code in finally block, even though exceptions are not anticipated.
finalize() – This method is associated with garbage collection. Just before collecting the garbage by the system (discarding an object from its scope), this method is invoked automatically.
Thanks