lundi 9 janvier 2017

Generation of 4 non repeating random numbers using arrays in java

I have this array

int [] marc = new int[4];

i need to insert a set of non repeating random numbers in the range of 1-10 to it

i'm using this for loop to set random numbers

for (he = 0; he < 4; he++) {

            marc[he] = rn.nextInt(10 - 1 + 1) + 1;

            marc[he]++; }

it gives me random numbers but repeated ones inside the array

i'm also using

java.util.Random;




Aucun commentaire:

Enregistrer un commentaire