I know how to do it between 0 and 100, but I can I set the floor?
This is how I do 0 - 100..
int randomNum = (int) Math.ceil(Math.random(开发者_开发知识库) * 100);
Generate a random number from 0 to 25 and add 75. :)
int randomNum = (int) Math.ceil(Math.random() * 25) + 75;
Generate a number between 0 and 25 and then add 75.
Do it between zero and 25 and add 75.
I know this is answered already but correct answer did not have code snippet. So here is a little code snippet:
int randomNum = 0;
Random ran = new Random();
randomNum = ran.nextInt(25) + 75;
精彩评论