Could anyone help me with why I'm unable to add to either of the lists created? The second list is only created to illustrate the problem. Thanks for any help!
import java.util.ArrayList;
import java.util.List;
import org.newdawn.slick.Image;
public class Snake {
private Image head = new Image("data/head.png");
private static Image body = new Image("data/body.png");
ArrayList<Point> snakeCoords = new ArrayList<Point>(3);
Point headCoord = new Point(300, 300);
Point firstBody = new Point(300, 325);
Point secondBody = new Point(300, 350);
snakeCoords.add(headCoord);
List<String> list = new ArrayList<String>();
list.add("Does this work");
}
If the code you posted is accurate, you need to have the method calls placed in a method or the constructor. You can initialize variables outside of methods, but that's it.