title: Garbage collection -- two cases about linkedlist
body: <p>Case 1:
  If there is a LinkedList like this:</p>
  
  <pre><code>A --&gt; B --&gt; C --&gt; D
  </code></pre>
  
  <p>if I make <code>A.next = null</code>, so the graph would be <code>A --&gt; null</code>  and  <code>B --&gt; C --&gt; D</code> </p>
  
  <p>Will node <code>B,C,D</code> be garbage collected?</p>
  
  <p>Case 2:
  If there is a LinkedList like this:</p>
  
  <pre><code>A --&gt; B --&gt; C --&gt; D
  </code></pre>
  
  <p>if I make <code>A.next = A.next.next</code>, so the graph would be <code>A --&gt; C --&gt; D</code> but also B still points to C like this: <code>B --&gt; C</code> Will node <code>B</code> be garbage collected?</p>