public class RandomUtils
extends java.lang.Object
RandomUtils
is a wrapper that supports all possible
Random
methods via the Math.random()
method and its system-wide Random
object.
Modifier and Type | Field and Description |
---|---|
static java.util.Random |
JVM_RANDOM |
Constructor and Description |
---|
RandomUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
nextBoolean()
Returns the next pseudorandom, uniformly distributed boolean value
from the Math.random() sequence.
|
static boolean |
nextBoolean(java.util.Random random)
Returns the next pseudorandom, uniformly distributed boolean value
from the given random sequence.
|
static double |
nextDouble()
Returns the next pseudorandom, uniformly distributed float value
between
0.0 and 1.0 from the Math.random()
sequence. |
static double |
nextDouble(java.util.Random random)
Returns the next pseudorandom, uniformly distributed float value
between
0.0 and 1.0 from the given Random
sequence. |
static float |
nextFloat()
Returns the next pseudorandom, uniformly distributed float value
between
0.0 and 1.0 from the Math.random()
sequence. |
static float |
nextFloat(java.util.Random random)
Returns the next pseudorandom, uniformly distributed float value
between
0.0 and 1.0 from the given Random
sequence. |
static int |
nextInt()
Returns the next pseudorandom, uniformly distributed int value
from the Math.random() sequence.
|
static int |
nextInt(int n)
Returns a pseudorandom, uniformly distributed int value
between
0 (inclusive) and the specified value
(exclusive), from the Math.random() sequence. |
static int |
nextInt(java.util.Random random)
Returns the next pseudorandom, uniformly distributed int value
from the given
random sequence. |
static int |
nextInt(java.util.Random random,
int n)
Returns a pseudorandom, uniformly distributed int value
between
0 (inclusive) and the specified value
(exclusive), from the given Random sequence. |
static long |
nextLong()
Returns the next pseudorandom, uniformly distributed long value
from the Math.random() sequence.
|
static long |
nextLong(java.util.Random random)
Returns the next pseudorandom, uniformly distributed long value
from the given Random sequence.
|
public static int nextInt()
Returns the next pseudorandom, uniformly distributed int value from the Math.random() sequence.
public static int nextInt(java.util.Random random)
Returns the next pseudorandom, uniformly distributed int value
from the given random
sequence.
random
- the Random sequence generator.public static int nextInt(int n)
Returns a pseudorandom, uniformly distributed int value
between 0
(inclusive) and the specified value
(exclusive), from the Math.random() sequence.
n
- the specified exclusive max-valuepublic static int nextInt(java.util.Random random, int n)
Returns a pseudorandom, uniformly distributed int value
between 0
(inclusive) and the specified value
(exclusive), from the given Random sequence.
random
- the Random sequence generator.n
- the specified exclusive max-valuepublic static long nextLong()
Returns the next pseudorandom, uniformly distributed long value from the Math.random() sequence.
public static long nextLong(java.util.Random random)
Returns the next pseudorandom, uniformly distributed long value from the given Random sequence.
random
- the Random sequence generator.public static boolean nextBoolean()
Returns the next pseudorandom, uniformly distributed boolean value from the Math.random() sequence.
public static boolean nextBoolean(java.util.Random random)
Returns the next pseudorandom, uniformly distributed boolean value from the given random sequence.
random
- the Random sequence generator.public static float nextFloat()
Returns the next pseudorandom, uniformly distributed float value
between 0.0
and 1.0
from the Math.random()
sequence.
public static float nextFloat(java.util.Random random)
Returns the next pseudorandom, uniformly distributed float value
between 0.0
and 1.0
from the given Random
sequence.
random
- the Random sequence generator.public static double nextDouble()
Returns the next pseudorandom, uniformly distributed float value
between 0.0
and 1.0
from the Math.random()
sequence.
public static double nextDouble(java.util.Random random)
Returns the next pseudorandom, uniformly distributed float value
between 0.0
and 1.0
from the given Random
sequence.
random
- the Random sequence generator.