mercredi 18 janvier 2017

Getting an bounding error from Random

I'm trying to produce a random integer using Random in a while loop.

do{
   vertSpot = rand.nextInt(vertSpot);
   horizSpot = rand.nextInt(horizSpot);
}while(vertSpot <= 3 || horizSpot <= 3)`

Exception in thread "main" java.lang.IllegalArgumentException: bound must be positive

vertSpot and horizSpot are not zero.

What is happening? Is there a way to produce a random integer greater than three? Because apparently, I don't know how.




Aucun commentaire:

Enregistrer un commentaire