September 2011
Beginner
650 pages
15h 47m
English
Try This 4-2 Demonstrate Garbage Collection and Finalization
![]()
Because garbage collection runs sporadically in the background, it is not trivial to demonstrate it. However, one way it can be done is through the use of the finalize( ) method. Recall that finalize( ) is called when an object is about to be recycled. As explained, objects are not necessarily recycled as soon as they are no longer needed. Instead, the garbage collector waits until it can perform its collection efficiently, usually when there are many unused objects. Thus, to demonstrate garbage collection via the finalize( ) method, you often need to create and destroy a large number ...
Read now
Unlock full access