I have two classes
Class A { //constructor } Class B { private A a; public B() { a = new A(); } }
Suppose I u
The GC is smart enough to follow paths in graphs of objects in order to check if the existing references to some object are reachable. It can even detect cycles (like, in your case, if b held a reference to a and a held a reference to b.
b
a