I am trying to make an arraylist of players in my game. However, i get a NullPointer when trying to add a player (string for testing purposes), in the init method. Here’s the code:
public class Chat extends BasicGame{
private Board board;
private Player player;
private ArrayList<String> testList;
private mySQL database;
public Chat()
{
super("MovingSystem");
}
@Override
public void init(GameContainer gc) throws SlickException {
this.player = new Player("Patrick");
this.board = new Board();
testList.add("Test");
}
Why is it failing?