title: Add object to ArrayList at specified index
body: <p>I think it's a fairly simple question, but I can't figure out how to do this properly.</p>
  <p>I've got an empty arraylist:</p>
  <pre><code>ArrayList&lt;object&gt; list = new ArrayList&lt;object&gt;();
  </code></pre>
  <p>I've got some objects In which I want to add object and each object has to be at a certain position. It is necessary however that they can be added in each possible order. When I try this, it doesn't work and I get an <code>IndexOutOfBoundsException</code>:</p>
  <pre><code>list.add(1, object1)
  list.add(3, object3)
  list.add(2, object2)
  </code></pre>
  <p>What I have tried is filling the <code>ArrayList</code> with <code>null</code> and then doing the above. It works, but I think it's a horrible solution. Is there another way to do this?</p>