Make a variable return a random number?
I need to know how to quickly make a variable return a random number, in PHP if i wanted a variable to return a random number it'd look like this using a built in function,
(int)$my_variable = rand(0,10); // returns 0 through 10 randomly
How can i do this with Java if say my variable looks like this.
public Integer madeThisUp = 1; // Needs to be random 0-10 aswell..
I can't find any tutorials on this that make clear sense to me, :-\
[469 byte] By [
sw0o0sha] at [2007-11-27 6:56:45]

> > Forget Math.random().
>
> why?
1) java.util.Random gives better distribution.
2) java.util.Random has a bunch of methods that correspond directly to common uses of random numbers. I can't imagine a situation where Math.random would be easier to understand.
jverda at 2007-7-12 18:33:46 >

> 2) java.util.Random has a bunch of methods that
> correspond directly to common uses of random numbers.
> I can't imagine a situation where Math.random would
> be easier to understand.
case in point, when a method is provided for you but you
try to reinvent it with:
int i = (int) (Math.random() * 10);