@Deprecated
public class RandomUtils
extends java.lang.Object
Random
class.
Caveat: Instances of Random
are not cryptographically secure.
Please note that the Apache Commons project provides a component dedicated to pseudo-random number generation, namely Commons RNG, that may be a better choice for applications with more stringent requirements (performance and/or correctness).
Constructor and Description |
---|
RandomUtils()
Deprecated.
RandomUtils instances should NOT be constructed in standard
programming. |
Modifier and Type | Method and Description |
---|---|
static boolean |
nextBoolean()
Deprecated.
Generates a random boolean value.
|
static byte[] |
nextBytes(int count)
Deprecated.
Generates an array of random bytes.
|
static double |
nextDouble()
Deprecated.
Generates a random double within 0 - Double.MAX_VALUE.
|
static double |
nextDouble(double startInclusive,
double endExclusive)
Deprecated.
Generates a random double within the specified range.
|
static float |
nextFloat()
Deprecated.
Generates a random float within 0 - Float.MAX_VALUE.
|
static float |
nextFloat(float startInclusive,
float endExclusive)
Deprecated.
Generates a random float within the specified range.
|
static int |
nextInt()
Deprecated.
Generates a random int within 0 - Integer.MAX_VALUE.
|
static int |
nextInt(int startInclusive,
int endExclusive)
Deprecated.
Generates a random integer within the specified range.
|
static long |
nextLong()
Deprecated.
Generates a random long within 0 - Long.MAX_VALUE.
|
static long |
nextLong(long startInclusive,
long endExclusive)
Deprecated.
Generates a random long within the specified range.
|
public RandomUtils()
RandomUtils
instances should NOT be constructed in standard
programming. Instead, the class should be used as
RandomUtils.nextBytes(5);
.
This constructor is public to permit tools that require a JavaBean instance to operate.
public static boolean nextBoolean()
public static byte[] nextBytes(int count)
count
- the size of the returned arrayjava.lang.IllegalArgumentException
- if count
is negativepublic static double nextDouble()
nextDouble(double, double)
public static double nextDouble(double startInclusive, double endExclusive)
startInclusive
- the smallest value that can be returned, must be non-negativeendExclusive
- the upper bound (not included)java.lang.IllegalArgumentException
- if startInclusive > endExclusive
or if
startInclusive
is negativepublic static float nextFloat()
nextFloat(float, float)
public static float nextFloat(float startInclusive, float endExclusive)
startInclusive
- the smallest value that can be returned, must be non-negativeendExclusive
- the upper bound (not included)java.lang.IllegalArgumentException
- if startInclusive > endExclusive
or if
startInclusive
is negativepublic static int nextInt()
nextInt(int, int)
public static int nextInt(int startInclusive, int endExclusive)
startInclusive
- the smallest value that can be returned, must be non-negativeendExclusive
- the upper bound (not included)java.lang.IllegalArgumentException
- if startInclusive > endExclusive
or if
startInclusive
is negativepublic static long nextLong()
nextLong(long, long)
public static long nextLong(long startInclusive, long endExclusive)
startInclusive
- the smallest value that can be returned, must be non-negativeendExclusive
- the upper bound (not included)java.lang.IllegalArgumentException
- if startInclusive > endExclusive
or if
startInclusive
is negativeCopyright © 2010 - 2023 Adobe. All Rights Reserved