final, finally and finalize are java keywords which can be described as below....
final : Please follow here to know about final keyword.
finally : finally is a java block which gets executed whenever try block exits.finally block is executed even if an unexpected exception occurs hence finally block is a perfect place for developers to write application cleanup code.
Note : If JVM exits while try or catch is being executed finally may not get executed.
finalize : finalize() is a java method available in Object class , hence will be available in all the classes to be overridden. finalize() method gets called before garbage collection happens.finalize method is last chance to change object before it gets claimed for garbage collection. The problem which we face with finalize method is that its indefinite when it would get called and also after being called when would be the next garbage collection, hence its not advisable to release critical resources in finalize method as its not definite when that resource would be available to next running thread.
No comments:
Post a Comment