dimanche 23 août 2020

How to use the Random class to choose random elements from an array in java [closed]

I've been using the Math.random() method to generate random numbers in the past. However, I've been asked to generate a list of 100 numbers from the set (6,10,14,18,22) using the Random class, the question says the output has to be random but every time I run it I must get the same list. I tried looking for a method online for the Random class that chooses random elements from an array and chooses the same ones every time but couldn't find anything.

I don't need to know how to make the program, I just need to know the appropriate method to use




Aucun commentaire:

Enregistrer un commentaire