f you want to mimic in Java the functionality of Cs destruct

f you want to mimic in Java the functionality of C++\'s destructor method (i.e., it gets called as soon as you are finished using an object), why is the finalize method the wrong way to implement this functionality?

Solution

In C++,the programmer knows when and where the destructor will be called. But in java finalize() is called by the garbage collector on an object when garbage collection determines that there are no more references to the object. The programmer does not know when finalize() will be executed. So finalize() is the wrong way to implement this functionality.

f you want to mimic in Java the functionality of C++\'s destructor method (i.e., it gets called as soon as you are finished using an object), why is the finaliz

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site