o
finalize()
method is used to perform some action when an object
is destroyed.
o For
example, if an object is holding some non-java resources such as file handle or
character font, then such resources must be freed before the object is destroyed.
o To
add a finalizer to a class, we define the finalize()
method.
o The
Java run time call the finalize() method
whenever it is about to recycle an object of that class.
o The
finalize() method has the general
form:
protected void finalize()
{
//finalization code
}
No comments:
Write comments