Adding items to empty List at specific locations in java
<p>Is there any way I can make the below code work without commenting the 3rd line.</p>

<pre><code>    List&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();
    list.add(0,0);
    //list.add(1,null);
    list.add(2,2);
</code></pre>

<p>I want to add items to list at specific locations. But if I don't change the index to Nth position I am not being able to add at Nth as told in this <a href="http://stackoverflow.com/questions/2534413/index-out-of-bounds-error/2534454#2534454">answer</a>.</p>

<p>I can't use a map because I don't want to miss a value when the keys are same. Also adding null values to a list for large lists will be an overhead. When there is a collision I want the item to take the next position(nearest to where it should have been). </p>

<p>Is there any <strong>List implementation that shifts index before it tries to add the item</strong>?</p>
