mardi 28 février 2017

avoiding off by one error when generating random numbers [duplicate]

This question already has an answer here:

I have the following code:

Random random = new Random();
int num1 = random.nextInt(5);

What are my possible values for num1?

0, 1, 2, 3, 4, 5

or

0, 1, 2, 3, 4




Aucun commentaire:

Enregistrer un commentaire