+ 2
How to print a random number between two numbers?
The random number should be between m and n,where m=5 and n = 10
2 Answers
+ 7
int x = rand.nextInt(6) + 5;
rand.nextInt(6) means 0-5
Add 5 to it means 5-10
+ 4
randomNum = minimum + (int)(Math.random() * maximum);
or
Random rn = new Random();
int n = maximum - minimum + 1;
int i = rn.nextInt() % n;
randomNum = minimum + i;