Java - Removing object from array when it collides with player
<p>Im working on a falling blocks game in java where you have to move the player around the screen to dodge the blocks. Whenever you get hit by a block, depending on the block  type, it will either decrease or increase a int in the player class. Im having the problem that when the player is hit by the block the int keeps going down until the now invisible block is offscreen. Basically I just need a way to check through a object array and when a object meets a specified condition such as (delete == true) it will set the current position of that block in the array to null.</p>

<p>Method for updating the block position:</p>

<pre><code>public void dropFoods(int speed) {
    for (int x = 699 - speed; x &gt;= 0; x--) {
        for (int y = 0; y &lt; 7; y++) {
            if(x &gt; (699 - GUI.HEIGHT) - 10) {
                food[y][x] = null;
                continue;
            }
            food[y][x + speed] = food[y][x];
            food[y][x] = null;

        }
    }
}
</code></pre>

<p>Method for drawing the blocks (the food are the different types of blocks):</p>

<pre><code>for(int x = 0; x &lt; food.length; x++) {
            for(int y = 0; y &lt; food[x].length; y ++) {
                Object o = food[x][y];
                if(o instanceof Apple) {
                    new Apple(x * 100, y - Apple.HEIGHT, g);            
                }
                if(o instanceof Burger) {
                    new Burger(x * 100, y - Burger.HEIGHT, g);          
                }
            }
}
</code></pre>

<p>Method for detecting collision with player:</p>

<pre><code>if(Food.getHitBox().intersects(Player.hitBox())) {
        willDraw = false;
        Player.weight -= 1;
}
</code></pre>
