Garbage Collection

Java handles deallocation automatically.

And the automated deallocation is called garbage collection.

When no references to an object exist, and that object is eligible for garbage collection

The finalize( ) Method

The Java calls finalize( ) method whenever it is about to recycle an object.

finalize() is called just prior to garbage collection.

The finalize( ) method has this general form:


protected void finalize( ) 
{ 
    // finalization code here 
}

The keyword protected prevents access to finalize( ) by code defined outside its class.

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.