J2ME Ranom

How can I set an Integer which comes from the Random number, but the Random range is draw from 1-100?? ???

Thanks a lot~ :slight_smile:

;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

::slight_smile:

0 to 99. Since 100 % 100 = 0

Kev

:smiley: I see, thanks you very much :smiley: