[java] random numbers in java...?

Started by
2 comments, last by BriarLoDeran 23 years, 2 months ago
I am new to java. What is the java equivolent to rand() in C/C++? Thanks, Briar->LoDeran();
Advertisement
Math.random() returns a double in range 0.0-1.0
Gee Brain, what we gonna do tonight?
actually, i don''t think it reaches 1.0.
for example, if u want a random number between 1 and 5, you would do
Math.random()*5 + 1

min is 0.0*5 + 1 = 1
max is .999*5 + 1 = 5.995
life is unfair, take advantage of it.UNMB2 - if the link doesn't work, try clicking it :)
Thanks a lot guys. It was so simply I feel stupid, but often times feeling stupid is part of learning...! ...right?!?

Briar->LoDeran();

This topic is closed to new replies.

Advertisement