Garbage Collection in Java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Garbage Collection in Java

Hi, I have some questions concerning the Garbage collection in Java. When we use the finalize() method in our program, the JVM can ignore the request ? And how many times it can be called.

16th Aug 2018, 9:12 AM
Dababi Mohamed Amine
Dababi Mohamed Amine - avatar
1 Answer
+ 1
Finalize is a normal method, you can call it as often as you want. The gc will call it once before it deletes the object, but running .finalize yourself does not trigger the gc to run.
16th Aug 2018, 10:09 AM
Schindlabua
Schindlabua - avatar