title: Garbage collector in java - set an object null
body: <p>Lets assume, there is a Tree object, with a root TreeNode object, and each TreeNode has leftNode and rightNode objects (e.g a BinaryTree object)</p>
  
  <p>If i call: </p>
  
  <pre><code>myTree = null;
  </code></pre>
  
  <p>what really happens with the related TreeNode objects inside the tree? Will be garbage collected as well, or i have to set null all the related objects inside the tree object?? </p>