Package org.apache.commons.lang3
Class RandomUtils
java.lang.Object
org.apache.commons.lang3.RandomUtils
Deprecated.
Use Apache Commons RNG's optimized UniformRandomProvider
Utility library that supplements the standard
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).
- Since:
- 3.3
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.RandomUtilsinstances should NOT be constructed in standard programming. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanDeprecated.Generates a random boolean value.static byte[]nextBytes(int count) Deprecated.Generates an array of random bytes.static doubleDeprecated.Generates a random double between 0 (inclusive) and Double.MAX_VALUE (exclusive).static doublenextDouble(double startInclusive, double endExclusive) Deprecated.Generates a random double within the specified range.static floatDeprecated.Generates a random float between 0 (inclusive) and Float.MAX_VALUE (exclusive).static floatnextFloat(float startInclusive, float endExclusive) Deprecated.Generates a random float within the specified range.static intnextInt()Deprecated.Generates a random int between 0 (inclusive) and Integer.MAX_VALUE (exclusive).static intnextInt(int startInclusive, int endExclusive) Deprecated.Generates a random integer within the specified range.static longnextLong()Deprecated.Generates a random long between 0 (inclusive) and Long.MAX_VALUE (exclusive).static longnextLong(long startInclusive, long endExclusive) Deprecated.Generates a random long within the specified range.
-
Constructor Details
-
RandomUtils
public RandomUtils()Deprecated.RandomUtilsinstances should NOT be constructed in standard programming. Instead, the class should be used asRandomUtils.nextBytes(5);.This constructor is public to permit tools that require a JavaBean instance to operate.
-
-
Method Details
-
nextBoolean
Deprecated.Generates a random boolean value.- Returns:
- the random boolean
- Since:
- 3.5
-
nextBytes
Deprecated.Generates an array of random bytes.- Parameters:
count- the size of the returned array- Returns:
- the random byte array
- Throws:
IllegalArgumentException- ifcountis negative
-
nextDouble
Deprecated.Generates a random double between 0 (inclusive) and Double.MAX_VALUE (exclusive).- Returns:
- the random double
- Since:
- 3.5
- See Also:
-
nextDouble
Deprecated.Generates a random double within the specified range.- Parameters:
startInclusive- the smallest value that can be returned, must be non-negativeendExclusive- the upper bound (not included)- Returns:
- the random double
- Throws:
IllegalArgumentException- ifstartInclusive > endExclusiveor ifstartInclusiveis negative
-
nextFloat
Deprecated.Generates a random float between 0 (inclusive) and Float.MAX_VALUE (exclusive).- Returns:
- the random float
- Since:
- 3.5
- See Also:
-
nextFloat
Deprecated.Generates a random float within the specified range.- Parameters:
startInclusive- the smallest value that can be returned, must be non-negativeendExclusive- the upper bound (not included)- Returns:
- the random float
- Throws:
IllegalArgumentException- ifstartInclusive > endExclusiveor ifstartInclusiveis negative
-
nextInt
Deprecated.Generates a random int between 0 (inclusive) and Integer.MAX_VALUE (exclusive).- Returns:
- the random integer
- Since:
- 3.5
- See Also:
-
nextInt
Deprecated.Generates a random integer within the specified range.- Parameters:
startInclusive- the smallest value that can be returned, must be non-negativeendExclusive- the upper bound (not included)- Returns:
- the random integer
- Throws:
IllegalArgumentException- ifstartInclusive > endExclusiveor ifstartInclusiveis negative
-
nextLong
Deprecated.Generates a random long between 0 (inclusive) and Long.MAX_VALUE (exclusive).- Returns:
- the random long
- Since:
- 3.5
- See Also:
-
nextLong
Deprecated.Generates a random long within the specified range.- Parameters:
startInclusive- the smallest value that can be returned, must be non-negativeendExclusive- the upper bound (not included)- Returns:
- the random long
- Throws:
IllegalArgumentException- ifstartInclusive > endExclusiveor ifstartInclusiveis negative
-