We don\'t have any destructor in Java as we have in C++.
Q1. How should we clean up any Object in java.
Q2. Is there any a
The finalize is used similar to a destructor, but, if you use the try...finally block for resources then you can open a resource and in the finally block you close the resource.
The finally block is always called, when the block is exited, either normally or through an exception being thrown.
Finalize is risky for resource management, as you don't know when it will be called, and if it closes an object that also has finalize then it can take a while.
The finally block is the better approach.