【发布时间】:2014-06-02 17:36:55
【问题描述】:
谁能帮我解释为什么我无法添加到任何一个创建的列表中?创建第二个列表只是为了说明问题。谢谢你的帮助!
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");
}
【问题讨论】:
-
只是为了确保您添加到方法或构造函数列表中的行?
-
也许你可以把函数调用放在一个方法中。
-
哈哈,天哪,非常感谢你们!