Class RandomUtils
RandomUtils is a wrapper that supports all possible
Random methods via the Math.random()
method and its system-wide Random object.
- Since:
- 2.0
- Version:
- $Id: RandomUtils.java 906320 2010-02-04 01:41:10Z sebb $
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReturns the next pseudorandom, uniformly distributed boolean value from the Math.random() sequence.static booleannextBoolean(Random random) Returns the next pseudorandom, uniformly distributed boolean value from the given random sequence.static doubleReturns the next pseudorandom, uniformly distributed float value between0.0and1.0from the Math.random() sequence.static doublenextDouble(Random random) Returns the next pseudorandom, uniformly distributed float value between0.0and1.0from the given Random sequence.static floatReturns the next pseudorandom, uniformly distributed float value between0.0and1.0from the Math.random() sequence.static floatReturns the next pseudorandom, uniformly distributed float value between0.0and1.0from the given Random sequence.static intnextInt()Returns the next pseudorandom, uniformly distributed int value from the Math.random() sequence.static intnextInt(int n) Returns a pseudorandom, uniformly distributed int value between0(inclusive) and the specified value (exclusive), from the Math.random() sequence.static intReturns the next pseudorandom, uniformly distributed int value from the givenrandomsequence.static intReturns a pseudorandom, uniformly distributed int value between0(inclusive) and the specified value (exclusive), from the given Random sequence.static longnextLong()Returns the next pseudorandom, uniformly distributed long value from the Math.random() sequence.static longReturns the next pseudorandom, uniformly distributed long value from the given Random sequence.
-
Field Details
-
JVM_RANDOM
An instance ofJVMRandom.
-
-
Constructor Details
-
RandomUtils
public RandomUtils()
-
-
Method Details
-
nextInt
public static int nextInt()Returns the next pseudorandom, uniformly distributed int value from the Math.random() sequence.
N.B. All values are >= 0.- Returns:
- the random int
-
nextInt
Returns the next pseudorandom, uniformly distributed int value from the given
randomsequence.- Parameters:
random- the Random sequence generator.- Returns:
- the random int
-
nextInt
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.- Parameters:
n- the specified exclusive max-value- Returns:
- the random int
-
nextInt
Returns a pseudorandom, uniformly distributed int value between
0(inclusive) and the specified value (exclusive), from the given Random sequence.- Parameters:
random- the Random sequence generator.n- the specified exclusive max-value- Returns:
- the random int
-
nextLong
public static long nextLong()Returns the next pseudorandom, uniformly distributed long value from the Math.random() sequence.
N.B. All values are >= 0.- Returns:
- the random long
-
nextLong
Returns the next pseudorandom, uniformly distributed long value from the given Random sequence.
- Parameters:
random- the Random sequence generator.- Returns:
- the random long
-
nextBoolean
public static boolean nextBoolean()Returns the next pseudorandom, uniformly distributed boolean value from the Math.random() sequence.
- Returns:
- the random boolean
-
nextBoolean
Returns the next pseudorandom, uniformly distributed boolean value from the given random sequence.
- Parameters:
random- the Random sequence generator.- Returns:
- the random boolean
-
nextFloat
public static float nextFloat()Returns the next pseudorandom, uniformly distributed float value between
0.0and1.0from the Math.random() sequence.- Returns:
- the random float
-
nextFloat
Returns the next pseudorandom, uniformly distributed float value between
0.0and1.0from the given Random sequence.- Parameters:
random- the Random sequence generator.- Returns:
- the random float
-
nextDouble
public static double nextDouble()Returns the next pseudorandom, uniformly distributed float value between
0.0and1.0from the Math.random() sequence.- Returns:
- the random double
-
nextDouble
Returns the next pseudorandom, uniformly distributed float value between
0.0and1.0from the given Random sequence.- Parameters:
random- the Random sequence generator.- Returns:
- the random double
-