I am a little confused to how garbage collection in Java works.
I get that an object becomes eligible for garbage collection when there are no more live references to it, but what if it has references to live objects?
Lets say i have a collection of nodes that again references more nodes
List
1 -> Node a -> Node b
2 -> Node c -> Node d
3 -> Node d -> Node c
4 -> Node e
5
Now if i delete the list, node c d and e should be garbage collected. Node e has no more references to it, and node c and d have cyclical references.
But what about Node a? Will it be garbage collected?
Will it be different whether or not node b has outside live references? Say if node b has a reference to it from a different place, will that make node a stay in memory?