mercredi 23 novembre 2016

Generating a specified amount of random numbers

Okay, so I have a method that prints one random number

public void printOneRandomNumber() {

    System.out.println(x.nextInt());
}

How do I make the same sort of method that would take in an int parameter specifying how many random numbers to print. For example, passing in 10 would print 10 random numbers. I am not trying to specify the range that the random number should be generated in, just the amount of them.




Aucun commentaire:

Enregistrer un commentaire