jeudi 5 avril 2018

Generate a Random Numerical String Java

I have this array here

String[] debug_board_state  = new String[7];
    debug_board_state[0] = "0,3,0,0,3,0,2";
    debug_board_state[1] = "1,0,2,0,0,1,2";
    debug_board_state[2] = "0,2,0,0,0,0,0";
    debug_board_state[3] = "0,0,3,0,3,0,4";
    debug_board_state[4] = "2,0,0,0,0,1,0";
    debug_board_state[5] = "0,1,0,0,1,0,2";
    debug_board_state[6] = "2,0,3,0,0,2,0";

I need to generate random values for "0,3,0,0,3,0,2" "1,0 etc...

I have tried to use the Random function with char and int

Random rand = new Random();
      char c = (char)(rand.nextInt(5) + '0');

but this gives me an erro that the char needs to be a string i can't find any solutions online so here i am.




Aucun commentaire:

Enregistrer un commentaire