dimanche 19 novembre 2017

Generate 100 random numbers between 1-10 in java?

I want to generate a 100 unique random numbers, but the numbers need to be in the range of 1-10. Right now i am doing this...

for (int i = 0; i < 100; i++) {
    int n = rand.nextInt(10) + 1;
    arr[i] = n;
}

The numbers could be float or double as long as they are unique and between the range of 1-10.




Aucun commentaire:

Enregistrer un commentaire