public class RandomUtils extends Object
Utility library that supplements the standard Random class.
| Constructor and Description |
|---|
RandomUtils()
RandomUtils instances should NOT be constructed in standard
programming. |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
nextBytes(int count)
Creates an array of random bytes.
|
static double |
nextDouble(double startInclusive,
double endInclusive)
Returns a random double within the specified range.
|
static float |
nextFloat(float startInclusive,
float endInclusive)
Returns a random float within the specified range.
|
static int |
nextInt(int startInclusive,
int endExclusive)
Returns a random integer within the specified range.
|
static long |
nextLong(long startInclusive,
long endExclusive)
Returns 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 byte[] nextBytes(int count)
Creates an array of random bytes.
count - the size of the returned arrayIllegalArgumentException - if count is negativepublic static int nextInt(int startInclusive, int endExclusive)
Returns a random integer within the specified range.
startInclusive - the smallest value that can be returned, must be non-negativeendExclusive - the upper bound (not included)IllegalArgumentException - if startInclusive > endExclusive or if
startInclusive is negativepublic static long nextLong(long startInclusive, long endExclusive)
Returns a random long within the specified range.
startInclusive - the smallest value that can be returned, must be non-negativeendExclusive - the upper bound (not included)IllegalArgumentException - if startInclusive > endExclusive or if
startInclusive is negativepublic static double nextDouble(double startInclusive, double endInclusive)
Returns a random double within the specified range.
startInclusive - the smallest value that can be returned, must be non-negativeendInclusive - the upper bound (included)IllegalArgumentException - if startInclusive > endInclusive or if
startInclusive is negativepublic static float nextFloat(float startInclusive, float endInclusive)
Returns a random float within the specified range.
startInclusive - the smallest value that can be returned, must be non-negativeendInclusive - the upper bound (included)IllegalArgumentException - if startInclusive > endInclusive or if
startInclusive is negativeCopyright © 2001–2015 The Apache Software Foundation. All rights reserved.