Currently, we are working on a shoot-em-up game. We have classes for both the bullets and the enemies. We have also created two arraylists where these elements can be found. Whenever a bullet hits an enemy, said enemy is supposed to simply disappear. Instead, we get this error.
void hit()
{
    for(int i = 0; i < Bullet.size(); i++)
    {
      Bullet bul = (Bullet) Bullet.get(i);
      Enemy enm = (Enemy)enemies.get(i);
      if(bul.x < enm.x + enm.l && bul.x > enm.x - enm.l && enm.y<bul.y)
      {
        enm.health -= 1;
        println("Pew");
        if(enm.health <= 0)
        {
          enm = null;
         enemies.remove(i);
        }
      }      
    }
}
 
     
    