title: Java ArrayList is throwing IndexOutOfBoundsException. Why?
body: <p>This is my current progress on a project. I am trying to implement this ArrayList stuff but file continues to trow the same exception. </p>
  
  <pre><code>import java.util.*;
  
     public class Numerican{
  
        public static void main( String [] args ){
  
          Scanner input = new Scanner(System.in);
  
          ArrayList&lt;Integer&gt; array = new ArrayList&lt;Integer&gt;(10);
  
          int count = input.nextInt() * 2;
  
          while (count &gt; 0){
             array.add( 0 );
             count = count - 1;
             array.add(count, 2);
          }
  
          array.add(2, input.nextInt());
          System.out.println(array.get(2));
  
        }
     }
  </code></pre>
  
  <p>It was my understanding that <code>= new ArrayList&lt;Integer&gt;(10);</code> would set the array size to 10. Did I do something wrong?</p>