title: Casting an array of Objects into an array of my intended class
body: <p>Just for review, can someone quickly explain what prevents this from working (on compile):</p>
  
  <pre><code>private HashSet data;
  
  ...
  
  public DataObject[] getDataObjects( )
  {
      return (DataObject[]) data.toArray();
  }
  </code></pre>
  
  <p>...and what makes this the way that DOES work:</p>
  
  <pre><code>public DataObject[] getDataObjects( )
  {
      return (DataObject[]) data.toArray( new DataObject[ Data.size() ] );
  }
  </code></pre>
  
  <p>I'm not clear on the mechanism at work with casting (or whatever it is) that makes this so.</p>