我試圖添加一個對象到一個矢量,當我使用下面的代碼粘貼時,我得到錯誤,說:「令牌上的語法錯誤,錯位的構造(S)。」和「令牌上的語法錯誤」gamePaddle「,VariableDecloratorID期望在此令牌之後。」我到處尋找,找不到我做錯了,他們都告訴我像這樣構建Vector。在啓動ListOfGameObjects.add(行...在Java中向矢量添加對象
class GameWorld {
/**
* Code that instantiate, hold, and manipulate GameOobjects and related game state data.
* @author Tyler Thomas
*
*/
Paddle gamePaddle = new Paddle();
Ball gameBall = new Ball();
Edge topEdge = new Edge(50, 150);
Edge bottomEdge = new Edge(50, 0);
Edge leftEdge = new Edge(0, 75);
Edge rightEdge = new Edge(100, 75);
Vector<GameObject> ListOfGameObjects = new Vector<GameObject>();
ListOfGameObjects.add(gamePaddle);
}