java.lang.Object | +----java.util.Random
An instance of this class is used to generate a stream of pseudorandom numbers. The class 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.)
If two instances of Random are created with the same
seed, and the same sequence of method calls is made for each, they
will generate and return identical sequences of numbers.
Many applications will find the random method in
class Math simpler to use.
long seed.
double value between 0.0 and
1.0 from this random number generator's sequence.
float
value between 0.0 and 1.0 from this random
number generator's sequence.
double value with mean 0.0 and standard
deviation 1.0 from this random number generator's sequence.
int
value from this random number generator's sequence.
long
value from this random number generator's sequence.
long seed.
public Random()
public Random(long seed)
long seed.
public synchronized void setSeed(long seed)
long seed.
protected synchronized int next(int bits)
public void nextBytes(byte bytes[])
public int nextInt()
int
value from this random number generator's sequence.
int
value from this random number generator's sequence.
public long nextLong()
long
value from this random number generator's sequence.
long
value from this random number generator's sequence.
public float nextFloat()
float
value between 0.0 and 1.0 from this random
number generator's sequence.
float
value between 0.0 and 1.0 from this
random number generator's sequence.
public double nextDouble()
double value between 0.0 and
1.0 from this random number generator's sequence.
double value between 0.0 and
1.0 from this random number generator's sequence.
public synchronized double nextGaussian()
double value with mean 0.0 and standard
deviation 1.0 from this random number generator's sequence.
double value with mean 0.0 and
standard deviation 1.0 from this random number
generator's sequence.
![]()