title: Understanding ArrayBuffer in Scala
body: <p>I'm trying to undersatend how removing elements from <code>ArrayBuffer</code> works. Here is it:</p>
  
  <pre><code>  override def remove(n: Int, count: Int) {
      if (count &lt; 0) throw new IllegalArgumentException("removing negative number of elements: " + count.toString)
      else if (count == 0) return  // Did nothing
      if (n &lt; 0 || n &gt; size0 - count) throw new IndexOutOfBoundsException("at " + n.toString + " deleting " + count.toString)
      copy(n + count, n, size0 - (n + count))
      reduceToSize(size0 - count)
    }
  </code></pre>
  
  <p>The thing is copy is implemented as follows:</p>
  
  <pre><code>protected def copy(m: Int, n: Int, len: Int) {
    scala.compat.Platform.arraycopy(array, m, array, n, len)
  }
  </code></pre>
  
  <p>It means it just copies the content of the new array to the same array <strong><em>without resizing it</em></strong>. In contrast, <code>ArrayList</code> in <code>JDK</code> resizes array as long as we delete elements from it.</p>
  
  <p>Where is my understanding wrong?</p>