| Author |
Is this true in Garbage Collection
|
Sreeraj Harilal
Ranch Hand
Joined: May 09, 2006
Posts: 45
|
|
|
Can we use a Garbage collected object again?
|
SCJP 5.0<br />SCWCD 1.4<br />SCBCD 1.3<br />SCEA part 1
|
 |
Deepak Bala
Bartender
Joined: Feb 24, 2006
Posts: 6603
|
|
|
If you override the finalize method and some how save the object from being garbage collected ( eg: you save the reference to that object ) then the object will not be garbage collected. Once an object is garbage collected it cannot be reached because it has been removed from memory. An object is GC ed only when no reference can reach it , or when an island of isolation occurs.
|
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
Srinivasa Raghavan
Ranch Hand
Joined: Sep 28, 2004
Posts: 1228
|
|
In addition : finalize() method will be called only once in the life time of an object. So even if you override the finalize method and save the object from being garbage collected, finalize() will not be called when it's again eligible for GC.
|
Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
|
 |
Sreeraj Harilal
Ranch Hand
Joined: May 09, 2006
Posts: 45
|
|
I read from somewhere that we can use an object after its finalize method called. I think finalize is called only before the GC is taken place. right? Please give me an explanation.
|
 |
 |
|
|
subject: Is this true in Garbage Collection
|
|
|