How does Garbage Collection in Java work?
Posted
by Bright010957
on Stack Overflow
See other posts from Stack Overflow
or by Bright010957
Published on 2010-03-12T09:44:23Z
Indexed on
2010/03/12
9:47 UTC
Read the original article
Hit count: 557
garbage-collection
|java
I was wondering how the garbage collector in Java deals with the following situation.
Object A has a reference to Object B and Object B has a reference to Object C. The main program has a reference to Object A. So you can use Object B trough Object A, and Object C trough Object B trough Object A.
What happens to Object B and Object C, if the link between Object A and Object B is set to null?
Should Object B and Object C now been collected by the Garbage Collector? I mean there is still a connection between Object B and Object C.
© Stack Overflow or respective owner