title: remove objects from arraylist is doing strange things
body: <p>In the code below, i want the balls to change from <code>ArrayList ballList</code> to another <code>ArrayList oldBalls</code> as soon as their age turns higher than a threshold value.</p>
  
  <p>This code should be very simple but i can't figure out why when the age is same as the threshold (not larger) they disappear and then they come back 2 frames later. </p>
  
  <p>I have checked related questions using iterators for ArrayLists in java but i think there should be a way to do this in processing without java.
  Also i cant seem to post any question on the processing forum even though i can sign in, no idea why... </p>
  
  <p>I have reduced the code to the minimum able to reproduce the error.</p>
  
  <pre><code>ArrayList &lt;Ball&gt; ballList;
  ArrayList &lt;Ball&gt; oldBalls;
  int threshold=4;
  PFont font;
  
  void setup(){
   size(400,400);
   frameRate(0.5);
   font=createFont("Georgia", 18);
   textFont(font);
   textAlign(CENTER, CENTER);
   ballList=new ArrayList&lt;Ball&gt;();
   oldBalls=new ArrayList&lt;Ball&gt;();
   noFill();
   strokeWeight(2);
  }
  
  void draw(){
    background(0);
    Ball b=new Ball(new PVector(10, random(height/10,9*height/10)),new PVector(10,0),0);
    ballList.add(b);
  
    stroke(0,0,200);
    for(int i=0;i&lt;oldBalls.size();i++){
      Ball bb=oldBalls.get(i);
      bb.update();
      bb.render();
      text(bb.age,bb.pos.x,bb.pos.y);
    }
  
    stroke(200,0,0);
    for(int i=0;i&lt;ballList.size();i++){
      Ball bb=ballList.get(i);
      bb.update();
      bb.render();
      bb.migrate();
      text(bb.age,bb.pos.x,bb.pos.y);
    }
  }
  
  class Ball{
    PVector pos;
    PVector vel;
    int age;
  
    Ball(PVector _pos, PVector _vel, int _age){
      pos=_pos;
      vel=_vel;
      age=_age;
    }
  
    void migrate(){
      if(age&gt;threshold){
        oldBalls.add(this);
        ballList.remove(this);
      }
    }
  
    void update(){
      pos.add(vel);
      age+=1;
    }
  
    void render(){
      ellipse(pos.x,pos.y,24,24);
    }
  }
  </code></pre>
  
  <p>Note how balls labelled with age=threshold suddenly disappear...</p>