when code has below relationship, b , c garbage collected if disconnect b? , why?thanks
class a{ b b; a(b b); } class b{ c c; b(c c); } class c{ c(); } class testtarget{ public void test{ c = new c; b = new b(c); = new a(b); = null; } }
if there working code of above scenario exist yes b , c collected gc. there no outgoing reference c , no incoming reference b there exist relationship between b , c. gc not collect objects of b , c immediately. after threshold number of gc cycles these object collected.