닷지(총알피하기)만드는데 java.util.ConcurrentModificationException 이런 오류가 떠서 찾아봤더니 Iterator을 쓰라길래
for (bullet b : white_bullet_list) {
if(b.tempX < 0 || b.tempX > width || b.tempY < 0 || b.tempY > height) {
b.aim(player_x, player_y);
}
b.move();
g.setColor(Color.WHITE);
g.fillOval((int)b.tempX, (int)b.tempY, bullet_size, bullet_size);
}
오류나는 이 부분을
Iterator it = white_bullet_list.iterator();
while(it.hasNext()){
if(b.tempX < 0 || b.tempX > width || b.tempY < 0 || b.tempY > height) {
b.aim(player_x, player_y);
}
b.move();
g.setColor(Color.WHITE);
g.fillOval((int)b.tempX, (int)b.tempY, bullet_size, bullet_size);
}
이렇게 바꿨더니 무한루프도는것같아요.. 뭐가틀린걸까요?
얌마 내가 잡아는 잘 모르지만, 딱 보니 이터레이터 다음값 있냐만 체크하고 지금값 버리고 다음값으로 이동하는 부분이 빠졌네. 이런 언어는 일찍 때려쳐라
뉴비 잡는 소리좀 안나게 하는 언어 써라
next써야되네여 감사합니다