Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

finalize() function

Sun Feb 15, 2009 12:26 am

finalize() function :
Garbage collectors delete objects when it has no reference pointing to it. Your object can has finalize () function. It is called before destroy of the object. This function is used to free any resource that is in use of the object. Finalize () function is a member Object class. As you should already know any class in java is inherited from object class. You can override the finalize function and specify what your object do before it destroy. There is no guarantee to invoke garbage collectors, hence no guarantee for finalize method to be called. So it is a good programming to free resource when you will not need it again When object has reference it is called unfinalized and when it has no reference is it is called finalizer reachable, because it can be only accessed in the finalize () function.

example :
Code:
protected void finalize() {

// clean up code 
}




Post a reply
  Related Posts  to : finalize() function
 object's finalize() in java     -  
 php function     -  
 srand function example     -  
 Function Recursion     -  
 Using the array_slice () Function     -  
 Function return more than one value     -  
 Nested function     -  
 function key recognition     -  
 array_key_exists function use     -  
 Using include function     -  

Topic Tags

Java OOP