org.apache.commons.lang.math

Class JVMRandom

public final class JVMRandom extends Random

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

Since: 2.0

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

Constructor Summary
JVMRandom()
Constructs a new instance.
Method Summary
booleannextBoolean()

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

voidnextBytes(byte[] byteArray)
Unsupported in 2.0.
doublenextDouble()

Synonymous to the Math.random() call.

floatnextFloat()

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

doublenextGaussian()
Unsupported in 2.0.
intnextInt()

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

intnextInt(int n)

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

longnextLong()

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

static longnextLong(long n)

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

voidsetSeed(long seed)
Unsupported in 2.0.

Constructor Detail

JVMRandom

public JVMRandom()
Constructs a new instance.

Method Detail

nextBoolean

public boolean nextBoolean()

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

Returns: the random boolean

nextBytes

public void nextBytes(byte[] byteArray)
Unsupported in 2.0.

Parameters: byteArray ignored

Throws: UnsupportedOperationException

nextDouble

public double nextDouble()

Synonymous to the Math.random() call.

Returns: the random double

nextFloat

public 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

nextGaussian

public double nextGaussian()
Unsupported in 2.0.

Returns: Nothing, this method always throws an UnsupportedOperationException.

Throws: UnsupportedOperationException

nextInt

public int nextInt()

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

Returns: the random int

nextInt

public 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

Throws: IllegalArgumentException when n <= 0

nextLong

public long nextLong()

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

Returns: the random long

nextLong

public static long nextLong(long n)

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

Parameters: n the specified exclusive max-value

Returns: the random long

Throws: IllegalArgumentException when n <= 0

setSeed

public void setSeed(long seed)
Unsupported in 2.0.

Parameters: seed ignored

Throws: UnsupportedOperationException

Copyright © 2001-2010 - Apache Software Foundation