I am taking the following code from another person of this forum. However, I have a question. Why does it print 112 sometimes? Should it not print 121 always?
finalize method gets executed during garbage collection.... so what gets printed depends on the order in which objects get garbage collected. To assume that objects get garbage collected in the same order it was released from reference is wrong. ie,
even if you do :
t1=null; t2=null;
It is not correct to assume that always t1 gets garbage collected first.
Yes it is the same code but different question. My question was about the order. And thanks. I learned today that there is no guarantee in which order things will get into garbage collection.
Regards
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads: