ArrayList Problems / get() & remove()

Don’t use the same name for your variable

  • ArrayList<Bullet> bullets;
    and
  • Bullet bullets = bullets.get(i);

Say (for example) :

  • Bullet b = bullets.get(i);

By the way for ArrayLists you can do this instead :

for(Bullet b : bullets){
    //Your code : b.move()...
}
3 Likes