java - values not being added to arraylist -


public static void main(string[] args)     {        list <int []> arraylist = new arraylist<int []>();  // array list hold child arrays        priorityqueue <state> open = new priorityqueue<state>();  // priority queue minimum huristics        list<state> closed = new arraylist<state>();     // create list of states  hold visited states        int [] arr = new int  [9];        for(int = 0; < 9; i++)        {            if(i == 1) arr[i] = 0;            else                arr[i] = + 1;        }         state check = new state(arr,0,0,0);       // for(int = 0; i< 9; i++)         //    system.out.println(arraylist.get(0)[i]);        arraylist =  gen_next(closed,arraylist,check);        int j = 0;        int [] x = new int [9];        system.out.println("from outside");        for(int = 1; i< 3;i++)        {                  x = (arraylist.get(i));             for(int k = 0; k < 9; k++)             system.out.print(x[k] + " ");             system.out.println("");              //system.out.println(x);        } } public static list<int []> gen_next(list <state> closed,list <int []> next_arrlist,state current)     {       //  list <int []> next_arrlist = new arraylist<int []>();         int [] cur_board = current.get_board();         int [] copy_arr = new int [cur_board.length];         int hole = current.gethole();         system.out.println(hole);          system.out.println(hole);         system.out.println("hello");         copy(cur_board, copy_arr);         if(hole == 0)         {              swap(copy_arr,hole,hole + 1);             next_arrlist.add(copy_arr);             for(int = 0; i< 9;i++)             system.out.print(next_arrlist.get(0)[i]);             system.out.println("");              copy(cur_board,copy_arr);              swap(copy_arr,hole,hole + 3);             next_arrlist.add(copy_arr);             for(int = 0; i< 9;i++)             system.out.print(next_arrlist.get(0)[i]);             system.out.println("");               copy(cur_board,copy_arr);           }         else if (hole == 1)         {             swap(copy_arr,hole,hole - 1);             next_arrlist.add(copy_arr);             for(int = 0; i< 9;i++)             {                 system.out.print(copy_arr[i] +" ");              }             system.out.println("");             for(int = 0; i< 9;i++)                 system.out.print(next_arrlist.get(0)[i]+" "); system.out.println("");             copy(cur_board, copy_arr);             swap(copy_arr,hole,hole + 1);                  next_arrlist.add(copy_arr);             copy(cur_board,copy_arr);             swap(copy_arr,hole , hole + 3);             for(int = 0; i< 9;i++)             {                  system.out.print(copy_arr[i]+" ");             }             next_arrlist.add(copy_arr);             system.out.println("");             for(int = 0; i< 9;i++)             {                  system.out.print(next_arrlist.get(1)[i]+" ");             }             copy(cur_board,copy_arr);         }         else if (hole == 2)         {             swap(copy_arr,hole , hole - 1);             for(int = 0; i<9;i++) system.out.print(copy_arr[i]+" ");             system.out.println(""); // value must reflected in arraylist             next_arrlist .add(copy_arr);             for(int = 0; i< 9;i++)                 system.out.print(next_arrlist.get(0)[i]+" "); system.out.println("");             copy(cur_board,copy_arr);             swap(copy_arr,hole, hole +3);             for(int = 0; i<9;i++) system.out.print(copy_arr[i]+" ");             system.out.println("");              next_arrlist.add(copy_arr);             for(int = 0; i< 9;i++)                 system.out.print(next_arrlist.get(0)[i]+" ");             copy(cur_board,copy_arr);         }      return next_arrlist; } 

i wrote code generate new arrays existing array , store each array in arraylist, arraylist here contains existing array eventhough printing conents of arraylist inside fub=nction produce correct result.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -