public class Random extends Object
Constructor and Description |
---|
Random()
Creates a new random number generator.
|
Random(long seed)
Creates a new random number generator using a single long seed: public Random(long seed) { setSeed(seed); } Used by method next to hold the state of the pseudorandom number generator.
|
Modifier and Type | Method and Description |
---|---|
protected int |
next(int bits)
Generates the next pseudorandom number.
|
boolean |
nextBoolean() |
void |
nextBytes(byte[] bytes) |
double |
nextDouble()
Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.
|
float |
nextFloat()
Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from this random number generator's sequence.
|
int |
nextInt()
Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence.
|
int |
nextInt(int n)
Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.
|
long |
nextLong()
Returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence.
|
void |
setSeed(long seed)
Sets the seed of this random number generator using a single long seed.
|
public Random()
public Random(long seed)
protected int next(int bits)
public double nextDouble()
public float nextFloat()
public int nextInt()
public int nextInt(int n)
public long nextLong()
public void setSeed(long seed)
public boolean nextBoolean()
public void nextBytes(byte[] bytes)