Hi friends
I want to know what is different among final, finally and finalize() in java.
Thank you.
Final, Finally and Finalize() in Java
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted May 27, 2012, 12:36 AM EDT
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