title: what's the usage of the code in the implementation of AbstractCollection's toArray Method
body: <pre><code>public Object[] toArray() {
      // Estimate size of array; be prepared to see more or fewer elements
      Object[] r = new Object[size()];
      Iterator&lt;E&gt; it = iterator();
      for (int i = 0; i &lt; r.length; i++) {
          if (! it.hasNext()) // fewer elements than expected
              return Arrays.copyOf(r, i);
          r[i] = it.next();
      }
      return it.hasNext() ? finishToArray(r, it) : r;
  }
  </code></pre>
  
  <p>here's the code of implementation of <code>AbstractCollection.toArray</code> method.</p>
  
  <pre><code>if (! it.hasNext()) // fewer elements than expected
      return Arrays.copyOf(r, i);
  </code></pre>
  
  <p>I don't understand the usage of the code above. I suspect the code is used to avoid the size changing while the the method is invoked. So I have two questions:</p>
  
  <ol>
  <li>What I suspect is right or wrong? if it's wrong, what's the usage of this code?</li>
  <li>If it's true, what situation can make the size changing while the method has been invoked?</li>
  </ol>