title: How does Java Garbage Collection work with Circular References?
body: <p>From my understanding, garbage collection in Java cleans up some objects if nothing else is 'pointing' to that object.</p>
  
  <p>My question is, what happens if we have something like this:</p>
  
  <pre><code>class Node {
      public object value;
      public Node next;
      public Node(object o, Node n) { value = 0; next = n;}
  }
  
  //...some code
  {
      Node a = new Node("a", null), 
           b = new Node("b", a), 
           c = new Node("c", b);
      a.next = c;
  } //end of scope
  //...other code
  </code></pre>
  
  <p><code>a</code>, <code>b</code>, and <code>c</code> should be garbage collected, but they are all being referenced by other objects.</p>
  
  <p>How does the Java garbage collection deal with this? (or is it simply a memory drain?)</p>