I am stuck in a very simple problem for more then 2 hours. I am trying to create a two dimensional array and fill it with a constructor. However, I couldn't pass this step.
public class Test
{
public State [][] test1= new State[4][3];//
public State test2[][]= new State[4][3];//
public State [][]test3;
public State test4[][];
public class State{
int position;
double reward;
int policy;
}
public Test(){
test1[1][1].position=1; // never worked
test2[1][3].position=2; //never worked
test3=new State[4][3];
test3[1][2].position=3; //never worked
test4=new State[4][3];
test4[2][2].position=4;//never worked
}
}
I am calling above function with following code
Test test= new Test();
Log.e("done","pass"); //I never reach here. the code always stuck on the constructor.
Object[5] array = new Object[5];allocates an array for 5 object references, but those references are still null.