title: LibGDX Making a single bullet kill only one enemy when enemies are overlapping
body: <p>I'm making a shooter with LibGDX. My code works when a single bullet hits a single enemy. When multiple enemies are stacked and the collision box of a bullet hits multiple enemy collision boxes, the game crashes with <strong>Exception in thread "LWJGL Application" java.lang.ArrayIndexOutOfBoundsException: -1</strong></p>
  
  <p>Correct me if I'm wrong, but I think this happens because the iterator tries to remove also as many objects from the bullet array as there were enemies killed in that collision, and while there's only one bullet for example killing three enemies the bullet array index goes below zero which causes the exception.</p>
  
  <p><strong>My question is:</strong> How can I modify the loop / code so, that one enemy dies with one bullet even though there are many enemies "stacked" and a bullet hits multiple enemies at once. Thank you.</p>
  
  <pre><code>bIter = bullets.iterator();
          while(bIter.hasNext()){
              b = bIter.next();           
              mIter = monsters.iterator();
              while(mIter.hasNext()){
                  m = mIter.next();
  
                  if(m.getBounds().overlaps(b.getBounds())){
  
                      mIter.remove();
                      bIter.remove();
  
                  }
              }
          }
  </code></pre>