Originally posted by Amy Cha:
From what I can remember, an object is eligible for garbage collection only after all of its references are set to null.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
cardBoard c3 = c1.go(c2); //c3 set to null
cardBoard c3 = c1.go(c2); //c3 set to null
Here 'c3' is Not an object, just reference variable.
Remember to create an object you have to use 'new' to instantiate it.
why is Short story=5 garbage collected? Is it because it isn't used anywhere in the program and is termed unreachable?
Originally posted by Ahmed Yehia:
This example has been corrected in the errata, and Short story = 200; not 5. So that each CardBoard object 'c1' 'c2' would contain different 'story' object instead of refering to only one object in the pool in case it were 5.
And as far as I know real exam questions about GC wont involve pool objects.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |