dimanche 29 octobre 2017

Generating Random Numbers Once in Java

I would like to generate random numbers in range [0,6] and only get each number once. For example: 3,4,2,1,5,6,0. How can i implement this in Java without using ArrayList and shuffle methods.An if-statement in which i will be checking the repetition of the numbers would take forever in a longer range i think.

int[][] ts=new int[4][7];
for(int i=0;i<4;i++){
for(int j=0;j<7;j++){
//ts[i][j]=Random in [0,6] once
}
} 




Aucun commentaire:

Enregistrer un commentaire