All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.util.Random
To create a new random number generator, use one of the following methods:
new Random() new Random(long seed)The form
new Random()
initializes the generator
to a value based on the current time. The form
new Random(long seed)
seeds the random number generator with
a specific initial value; use this if an application requires a repeatable
stream of pseudo-random numbers. The random number generator uses a 48-bit seed, which is modified using a linear congruential formula. See Donald Knuth, The Art of Computer Programming, Volume 2, Section 3.2.1. The generator's seed can be reset with the following method:
setSeed(long seed)To create a pseudo-random number, use one of the following functions:
nextInt() nextLong() nextFloat() nextDouble() nextGaussian()
long
seed.
double
value between 0.0 and 1.0.
float
value between 0.0 and 1.0.
double
value with mean 0.0 and standard
deviation 1.0.
int
value.
long
value.
long
seed.
public Random()
public Random(long seed)
long
seed.
public synchronized void setSeed(long seed)
long
seed.
public int nextInt()
int
value.
public long nextLong()
long
value.
public float nextFloat()
float
value between 0.0 and 1.0.
float
between 0.0 and 1.0 .
public double nextDouble()
double
value between 0.0 and 1.0.
float
between 0.0 and 1.0 .
public synchronized double nextGaussian()
double
value with mean 0.0 and standard
deviation 1.0.
double
.
All Packages Class Hierarchy This Package Previous Next Index