title: Create generic ArrayList with initialCapacity in generic class
body: <p>I'm createing a generic ring buffer and I would like to use array list as internal storage for data and I'd like to allocate array list with defined <code>capacity</code>.</p>
  <p>This is an example using Kotlin ArrayList:</p>
  <pre class="lang-kotlin prettyprint-override"><code>class RingBuffer&lt;T&gt;(private val capacity: Int) {
      private var buffer = ArrayList&lt;T&gt;(initialCapacity = capacity)
  }
  </code></pre>
  <p>When I compile the code, this error appears:</p>
  <blockquote>
  <p>Kotlin: None of the following functions can be called with the arguments supplied:
  public final fun  (): kotlin.collections.ArrayList /* = java.util.ArrayList <em>/ defined in kotlin.collections.ArrayList
  public final fun  (p0: (MutableCollection&lt;out T!&gt;..Collection&lt;T!&gt;?)): kotlin.collections.ArrayList /</em> = java.util.ArrayList <em>/ defined in kotlin.collections.ArrayList
  public final fun  (p0: Int): kotlin.collections.ArrayList /</em> = java.util.ArrayList */ defined in kotlin.collections.ArrayList</p>
  </blockquote>
  <p>I've tried to use Java ArrayList:</p>
  <pre class="lang-kotlin prettyprint-override"><code>import java.util.ArrayList
  class RingBuffer&lt;T&gt;(private val capacity: Int) {
      private var buffer = ArrayList&lt;T&gt;(capacity)
  }
  </code></pre>
  <p>In this case code compiles, but <code>buffer</code> has <code>size=0</code>, so array is not allocated.</p>
  <p>So the question is how to create and then allocate <code>ArrayList</code> with <code>default T</code> values?</p>