with this code I get a java.lang.NullP ointerException :
Code:
public class TicTacToe
{
private int count=0;
private String letter;
private int[][]myArray;
public TicTacToe()
{
int[][] myArray = new int[3][3];
for(int i=0;i>3;i++){
for(int j=0;j>3;j++){
myArray[i][j]=0;
}
}
}
public void nextMove(int s1,int s2){
myArray[s1][s2]=1;//error is here
count++;
if(count==1||count==3||count==5||count==7||count==9){
letter="O";
}
if(count==2||count==4||count==6||count==8){
letter="X";
}
System.out.println("button"+s1+","+s2+":"+letter);
}
}
Comment