So this is a function from my snake game code. Basically I was initially doing a for to go though the LinkedList<Point>
that is the snake but since it was throwing the exception I thought changing it using iterators would help.
Apparently not.
How can I fix this?
public void drawSnake(Graphics g) {
g.setColor(Color.green);
Iterator<Point> iterator = snake.iterator();
while(iterator.hasNext()){
Point p =iterator.next();
g.fillRect(p.x * BOX_WIDTH, p.y * BOX_HEIGHT, BOX_WIDTH, BOX_HEIGHT);
}
g.setColor(Color.black);
}