samedi 14 avril 2018

Random selection of a number from an array to put it in another array

I am writing code for a project in Java and i need to select a number from the array int [] numbers={1,2,3,4,5,6,7,8,9,10} and take the selected number and put it into another array but in the index - 1 of the second array..because i want the input on the second array to be like a human put that number there..For example, I want it to be in the position with index 5 not 6 (because the computer counts for 0 but we don't). The code i am writing is : int rndNumb = rnd.nextInt(numbers.length) - 1 , but it doesn't seem to work...(rnd is my random class object).




Aucun commentaire:

Enregistrer un commentaire