Is there a destructor for Java? I don't seem to be able to find any documentation on this. If there isn't, how can I achieve the same effect?
Thank you in advance.
EDIT: First of all I thank everyone for swift reply. I see a lot of very good answers there. To make my question more specific, I am writing an application that deals with data, and the specification say that there should be a 'reset' button that brings the application back to its original just launched state. However, all data have to be 'live' unless application is closed or reset button is pressed.
Being usually a C/C++ programmer, I thought this would be trivial to implement. (And hence I planned to implement it last.) I structured my program such that all the 'reset-able' objects would be in a same class so that I can just destroy all 'live' objects when reset button is pressed.
I was thinking, if all I did was just to dereference the data and wait for the garbage collector to collect them, wouldn't there be a memory leak if my user repeatedly entered data and pressed the reset button? I was also thinking, since Java is quite mature as a language, there should be a way to prevent this from happening or gracefully tackle this.
Once again, thank you all for kind attention. Appreciated.