title: Add buttons to ArrayList at the specifed index
body: <p>I am trying to add a button to an ArrayList, but when I specify the index an error comes up saying the index is out of bounds.</p>
  
  <p>I initiate the array like this:</p>
  
  <pre><code>ArrayList&lt;Button&gt; buttons = new ArrayList&lt;Button&gt;();
  </code></pre>
  
  <p>I have an Integer variable "order" which indicates the priority of the button. The button should be the first value in the array when it has priority 0. </p>
  
  <p>The exception comes up with the following statement:</p>
  
  <pre><code>buttons.add(order,btn);
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>The value of order is more than the size of the ArrayList. I am creating the buttons dynamically. How would I be able to specify the size of the array?</p>