lundi 3 juillet 2017

Java: How to generate a random number bigger than x, no maximum?

I just want to generate a random number bigger than x, without a maximum value, to operate with it afterwards. I've been searching for answers to my question but none of them match my problem: they refer to a restriction with minimum and maximum values. I want a simple code just like:

Random number = new Random();
int x = 0; //the minimum value
int finalNumber;//any positive random number, in this case; if, for example, x were 2, some number bigger than 2.

How can I get finalNumber?

Thanks for taking your time in posting an answer, I would really appreciate it.




Aucun commentaire:

Enregistrer un commentaire