org.apache.commons.lang.math

Class RandomUtils

public class RandomUtils extends Object

RandomUtils is a wrapper that supports all possible java.util.Random methods via the java.lang.Math#random() method and its system-wide Random object.

Since: 2.0

Version: $Id: RandomUtils.java 471626 2006-11-06 04:02:09Z bayard $

Author: Gary D. Gregory

Field Summary
static RandomJVM_RANDOM
An instance of JVMRandom.
Method Summary
static booleannextBoolean()

Returns 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 doublenextDouble()

Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from the Math.random() sequence.

static doublenextDouble(Random random)

Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from the given Random sequence.

static floatnextFloat()

Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from the Math.random() sequence.

static floatnextFloat(Random random)

Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from the given Random sequence.

static intnextInt()

Returns the next pseudorandom, uniformly distributed int value from the Math.random() sequence.

static intnextInt(Random random)

Returns the next pseudorandom, uniformly distributed int value from the given random sequence.

static intnextInt(int n)

Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), from the Math.random() sequence.

static intnextInt(Random random, int n)

Returns a pseudorandom, uniformly distributed int value between 0 (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 longnextLong(Random random)

Returns the next pseudorandom, uniformly distributed long value from the given Random sequence.

Field Detail

JVM_RANDOM

public static final Random JVM_RANDOM
An instance of JVMRandom.

Method Detail

nextBoolean

public static boolean nextBoolean()

Returns the next pseudorandom, uniformly distributed boolean value from the Math.random() sequence.

Returns: the random boolean

nextBoolean

public static boolean nextBoolean(Random random)

Returns the next pseudorandom, uniformly distributed boolean value from the given random sequence.

Parameters: random the Random sequence generator.

Returns: the random boolean

nextDouble

public static double nextDouble()

Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from the Math.random() sequence.

Returns: the random double

nextDouble

public static double nextDouble(Random random)

Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from the given Random sequence.

Parameters: random the Random sequence generator.

Returns: the random double

nextFloat

public static float nextFloat()

Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from the Math.random() sequence.

Returns: the random float

nextFloat

public static float nextFloat(Random random)

Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from the given Random sequence.

Parameters: random the Random sequence generator.

Returns: the random float

nextInt

public static int nextInt()

Returns the next pseudorandom, uniformly distributed int value from the Math.random() sequence.

Returns: the random int

nextInt

public static int nextInt(Random random)

Returns the next pseudorandom, uniformly distributed int value from the given random sequence.

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

public static int nextInt(Random random, int n)

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.

Returns: the random long

nextLong

public static long nextLong(Random random)

Returns the next pseudorandom, uniformly distributed long value from the given Random sequence.

Parameters: random the Random sequence generator.

Returns: the random long

Copyright © 2001-2005 - Apache Software Foundation