lass Garbage
{
int index;
static int count;
Garbage()
{
count++;
System.out.println("object"+count+" construct");
setID(count);
}
void setID(int id)
{
index=id;
}
protected void finalise()
{
System.out.println("object"+index+"ris reclained");
}
public static void main(String[] args)
{
new Garbage();
new Garbage();
new Garbage();
new Garbage();
System.gc();
}
} |