How do I generate a random integer between min and max in Java?
Construct a Random object at application startup:
Random random = new Random();
Then use Random.nextInt(int):
int randomNumber = random.nextInt(max + 1 - min) + min;
Note that the both lower and upper limits are inclusive.
You can use Random.nextInt(n). This returns a random int in [0,n). Just using max-min+1 in place of n and adding min to the answer will give a value in the desired range.