开发者

parent child relation in composite object?

I have a composite object (tree) with parent-child relationships.The tree can be upto n levels (say for e.g 10-12 levels)

Now suppose i have to remove an object at level 6 in the hierarchy.If i point its reference to null (while leaving the child object untouched) in Java then what happens to the 开发者_如何学JAVAchild objects under it (do they become available for garbage collection).


The child objects will get picked up by garbage collection if the reference the parent had was the only live reference to the child object in the entire application.


Only if you set the object itself to null, or it goes out of scope.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜