Check out example codes for "why are there no destructors in java?". It will help you in understanding the concepts better.

Code Example 1

Because Java is a garbage collected language you cannot predict when (or even if) an object will be destroyed. Hence there is no direct equivalent of a destructor.

Learn ReactJs, React Native from