ArrayList遍历时删除出现
for (Bullet b:bullets){
b.paint(gr);
}
做删除时需要用迭代方式删除
for (int i = 0; i < bullets.size(); i++) {
bullets.get(i).paint(gr);
}
第二种迭代器
for (Iterator<Bullet> it = bList.iterator(); it.hasNext();){
Bullet b = it.next();
if (!b.live) it.remove();
}