Can someone explain the finalize() method in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can someone explain the finalize() method in java?

26th Nov 2018, 12:49 PM
Mystery
Mystery - avatar
4 Answers
+ 3
Kurtis Odom No. Finalize is used to perform clean up processing just before object is garbage collected. And the final keyword is used before the method_name to prevent it from overriding.
9th Dec 2018, 2:12 PM
Mystery
Mystery - avatar
+ 2
My previous answers were wrong. The finalize method is used to prevent overriding of a method by a subclass. If a method is finalized, it cannot be overridden.
8th Dec 2018, 4:23 PM
Kurtis Odom
Kurtis Odom - avatar
+ 1
so do we have to call it explicitly everytime or it is an automatic process? and what would happen if we do not use it?
26th Nov 2018, 2:01 PM
Mystery
Mystery - avatar