How does Garbage Collection in Java work?

后端 未结 9 2155
生来不讨喜
生来不讨喜 2021-02-08 04:36

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

9条回答
  •  无人共我
    2021-02-08 05:38

    Should Object B and Object C now been collected by the Garbage Collector?

    Yes. Well, they are candidates for collection because there's no way to reach Object B and C through the root that is A.

提交回复
热议问题