title: Trouble running my code: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
body: <p>can someone help me out with this problem.  this is the error message I get:</p>
  
  <pre><code>Exception in thread "LWJGL Application" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
      at java.util.ArrayList.rangeCheck(ArrayList.java:635)
      at java.util.ArrayList.get(ArrayList.java:411)
      at com.mygdx.Papermadness.Papermadness.render(Papermadness.java:102)
      at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:206)
      at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
  </code></pre>
  
  <p>This is the code of my for loop through the huisArray (huis= house).</p>
  
  <pre><code>private ArrayList&lt;Sprite&gt; huisArray = new ArrayList&lt;Sprite&gt;();
  
  spriteBatch.begin();
  
      sprite.draw(spriteBatch);
  
  
  
       for (int i = 0; i &lt; huisArray.size(); i++) {
              huisArray.get(i).setY(huisArray.get(i).getY() - huisVelocity * delta);
  
                   if (huisArray.get(i).getY() &lt;= 200) {
                  huisArray.remove(huisArray.get(i));
              } 
  
          }
  
  
        if (huisArray.get(0).getY() &lt; 1200) {
              addNewHuis();
          }
  
       huisBatch.begin();
  
       for (int i = 0; i &lt; huisArray.size(); i++) {
              huisArray.get(i).setY(huisArray.get(i).getY() - huisVelocity * delta);
  
                   if (huisArray.get(i).getY() &lt;= 200) {
                  huisArray.remove(huisArray.get(i));
              } 
  
          }
  
  
        if (huisArray.get(0).getY() &lt; 1200) {
              addNewHuis();
          }
  
       huisBatch.begin();
  
  
        for (int i = 0; i &lt; huisArray.size(); i++) {
              huisBatch.draw(huisArray.get(i), huisArray.get(i).getX(), huisArray.get(i).getY());
          }
  spriteBatch.end();
      huisBatch.end();
  </code></pre>
  
  <p>The idea of this code is that houses at the two edges of the screen fall continuesly.</p>
  
  <p>Any help would be appreciated :)</p>