public class RandomUtils extends Object
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 a array of the specified length filled with 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)
count
- the size of the returned arraypublic static int nextInt(int startInclusive, int endExclusive)
startInclusive
- the smallest value that can be returned, must be non-negativeendExclusive
- the upper bound (not included), must be non-negativeIllegalArgumentException
- if startInclusive > endInclusive
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), must be non-negativeIllegalArgumentException
- if startInclusive > endInclusive
public static double nextDouble(double startInclusive, double endInclusive)
startInclusive
- the smallest value that can be returned, must be non-negativeendInclusive
- the upper bound (included), must be non-negativeIllegalArgumentException
- if startInclusive > endInclusive
public static float nextFloat(float startInclusive, float endInclusive)
startInclusive
- the smallest value that can be returned, must be non-negativeendInclusive
- the upper bound (included), must be non-negativeIllegalArgumentException
- if startInclusive > endInclusive
Copyright © 2001–2014 The Apache Software Foundation. All rights reserved.