Perry Smith

Java Questions & Answers

Archive

Home / Java Q & A Archive Page 4 / Java Q & A Archive / Java Main Page

new to java, how do you create random numbers?
Tuesday, 09-Mar-99 20:42:02
204.94.193.69 writes:
I can't seem to make the sense of how to make a random number in Java. like you load the Javascript, and it randomly picks a number for a value ex:

y = either1 or 2 or 3 or 4 or 5, get the point?

Zach(Crinnonboy)


Response
Re: new to java, how do you create random numbers?
Tuesday, 09-Mar-99 23:22:39
24.1.16.214 writes:
create an instance of the Random object and then use one of its methods to get the type of random number you want, for example:
Random pick = new Random();
int my_pick;

my_pick = pick.nextInt() % 5;


Random is in java.util.

-calyxa

Home / Java Q & A Archive Page 4 / Java Q & A Archive / Java Main Page