At the point when I run the program, it lets me know that my arralist index is somewhere in the range of 0 and 1 beyond the interball.
public class snake extends Actor { private head k; private ArrayList<Rectangle> body; private Rectangle first; public Snake() { body = new ArrayList<>(); k = new Head(); body.add(0, k); first = new Rectangle((k.width / 2 - 1) * k.dimension, k.height / 2 * k.dimension, k.dimension, k.dimension); body.add(1, first); } public void act() { for (int i = body.size(); i >= 0; i--) { body.get(i).moveTo(body.get(i - 1).getCenterX(), body.get(i - 1).getCenterY()); } } }
Can someone Tell what's the error i am doing?
Yes, you're posting a JAVA question to a Keil forum.