How can I set an Integer which comes from the Random number, but the Random range is draw from 1-100?? ???
Thanks a lot~
How can I set an Integer which comes from the Random number, but the Random range is draw from 1-100?? ???
Thanks a lot~
;DHi!
first create Random object like this…
private Random random = new Random( System.currentTimeMillis() );
next call this method:
int bound = 100;
int randomNumber;
randomNumber = Math.abs( random.nextInt()% bound );
i am not sure if the output will be from 0 to 100 OR 0 to 99 only… just try it though
:
0 to 99. Since 100 % 100 = 0
Kev
I see, thanks you very much