Trying to avoid a Force close after a bullet goes off screen
<p>So I'm just messing around learning to create a Space invaders type game. I can get the bad guys to move, Great!!. Hero moves, Great!! Bullets move, Great!! However I try to remove my bullets once they leave the screen as to not eat up all resources and it force closes on me once it gets rid of the bullet. It goes off the screen. Hits the int of -2 and then we use the remove() and boom. Force Close. </p>

<p>Here is my code. I'm wondering if they access the size() at the same time and just cause a force close because of it. </p>

<pre><code>//I removed everything that doesn't pertane to the bullets.
public class GameScreen{ 
    Bullet bullet = world.bullet;

    public GameScreen(Game game) {
        super(game);
        world = new World();
    }


    //Draws our bullets. 
    int bulletLength = bullet.bullets.size();
    for(int i = 0; i &lt; bulletLength; i++) {
        Placement part = bullet.bullets.get(i);
        x = part.x * 32 + 11;
        y = part.y * 32;
        g.drawPixmap(Assets.bullet, x, y);
    }
</code></pre>

<p>Class that holds my bullets. </p>

<pre><code>public class Bullet {
    public List&lt;Placement&gt; bullets = new ArrayList&lt;Placement&gt;();

    public Bullet() {

    }

    public void shoot(int x, int y){
        bullets.add(new Placement(x,y));
    }


    public void advance(){
    int len = bullets.size(); // gets all bullets.
    for(int i = 0; i &lt; len; i++) {
        bullets.get(i).y --;

        if (bullets.get(i).y &lt;= -2){//removes them once they are off the screen.
            bullets.remove(i);
        }
    }
}
</code></pre>

<p>This is what I use to keep track of placement.</p>

<pre><code>package com.learning.planecomander;

public class Placement {
public int x, y;

public Placement(int x, int y) {
    this.x = x;
    this.y = y;
}
}
</code></pre>
