Java Reference
In-Depth Information
This class creates an initial
FDemo
object called
ob
. Then, using
ob
, it creates
100,000 objects by calling
generator( )
on
ob
. This has the net effect of creating and
discarding 100,000 objects. At various points in the middle of this process, garbage
collection will take place. Precisely how often or when depends upon several factors,
such as the initial amount of free memory and the operating system. However, at
some point, you will start to see the messages generated by
finalize( )
. If you don't
see the messages, try increasing the number of objects being generated by raising the
count in the
for
loop.
4.
Here is the entire
Finalize.java
program: