Qus:    do we have DESTRUCTORS in Java? have never seen an example of a destructor program, only constructor?
Mar 29, 2021 12:22 1 Answers Views: 460 RANJIT
Prev Next
Answers (1)
SANJAY Mar 30, 2021 10:54
Answer:   We have something much better:
java.util.Cleaner
it uses PhantomReferences which can also be used of Cleaner doesn't already meet all requirements.
I actually once invented the Cleaner (I called it cleanup) because I didn't know it already existed as sun.misc.Cleaner before it became an official part of the JRE in Java 9. It's rather simple and just calls any code when some object doesn't exist anymore.

Post Your Answer
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect