NullPointer when using ArrayList

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?

Uhm, a little more info is required ^^

Where does it get the nullpointer exception?

You first have to create the ArrayList:


testList = new ArrayList<String>();

EDIT: @Regenuluz:
Muhahaha! :smiley:
My Error-finding eye jumps in. At first I thought you’d be faster at reporting the error ;D

Haha, I totally didn’t notice that it wasn’t initialized xD Good catch.

EDIT inception

Obiously! I guess i’ve been looking for too long at this code. :smiley: Thank you!