title: How to delete an array properly in Java
body: <p>I'm 4 days old in Java and from the tutorials I've searched, the instructors focus a lot of effort in explaining how to allocate a two dimensional array (e.g.) as such:</p>
  
  <pre><code>Foo[][] fooArray = new Foo[2][3];
  </code></pre>
  
  <p>... but I've not found any that explains how to delete them.</p>
  
  <p>From what is going on memory-wise, the variable <code>fooArray</code> will point to a block of memory in the heap, in which there are 2 elements. Each of the elements points to another block in the heap as well, which have 3 elements.</p>
  
  <p>That being said, could I just reference the first block of elements and the garbage collector will do the job?</p>
  
  <p><code>Foo[1] = null;</code> and <code>Foo[2] = null;</code></p>
  
  <p>Or do I have to null each of the instantiated Foo elements?</p>
  
  <p><code>Foo[1][1] = null;</code> <code>Foo[1][2] = null;</code> <code>Foo[1][3] = null;</code> ...</p>