NEVER call the finalize() method of an object manually. This is used only for a virtual machine. The VM will call it at the appropriate time (as part of the garbage collection process).
You can set the reference variable to null to make the object suitable for garbage collection earlier than otherwise, but this does not immediately terminate GC'd. (Note that the assignment operator uses the = ; == operator - a relational operator to verify the equality of its operands.)
If your object maintains the state that you want to ensure, it is cleared on demand and then implements another method for it. close() is a popular name for such methods. It is recommended to avoid finalize() implementation, if at all possible. The GC will automatically take care of most of the resources that you probably want to clear manually in finalize() .
source share