mercredi 6 mai 2015

Array that store instance of random class

How can i create a multi dimensional array that can store instance of a random class that can generate it's exact index position within the array it self based on the first 5 numbers that is randomly generated in between rang of 0 -9

That is what i have done so far:

/code

Random rand = new Random(); 
int[] arrayOfNumbers = new int[5];

for(int i = 0; i < arrayOfNumbers.length; i++) {
    arrayOfNumbers[i] = rand.nextInt(9) + 1;
} 

i still not getting the results i want, anybody knows what is wrong with my code?




Aucun commentaire:

Enregistrer un commentaire