I have a strange problem regarding null pointer exception. I'm posting the problematic code piece below :
public static void main(String[] args) {
BetHistory testObject = new BetHistory(6);
testObject.addResponse(2, 1, 0); // ERROR HERE
...
}
public class PlayerResponses {
public List<Integer> response;
public PlayerResponses() {
super();
response = new LinkedList<Integer>();
}
...
}
public class BetHistory {
PlayerResponses [][] responses;
int nPlayer;
public BetHistory(int totalPlayers) {
super();
responses = new PlayerResponses[4][totalPlayers];
nPlayer = totalPlayers;
}
public void addResponse(int response, int playerNo, int roundNo)
{
responses[roundNo][playerNo].response.add(response); // DUE TO HERE
}
...
}
Thanks in advance for your time.