Class JVMRandom
- java.lang.Object
 - 
- java.util.Random
 - 
- org.apache.commons.lang.math.JVMRandom
 
 
 
- 
- All Implemented Interfaces:
 java.io.Serializable
@Deprecated(since="2021-04-30") public final class JVMRandom extends java.util.RandomDeprecated.Commons Lang 2 is in maintenance mode. Commons Lang 3 should be used instead.JVMRandomis a wrapper that supports all possible Random methods via theMath.random()method and its system-wideRandomobject.It does this to allow for a Random class in which the seed is shared between all members of the class - a better name would have been SharedSeedRandom.
N.B. the current implementation overrides the methods
Random.nextInt(int)andRandom.nextLong()to produce positive numbers ranging from 0 (inclusive) to MAX_VALUE (exclusive).- Since:
 - 2.0
 - See Also:
 - Serialized Form
 
 
- 
- 
Constructor Summary
Constructors Constructor Description JVMRandom()Deprecated.Constructs a new instance. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleannextBoolean()Deprecated.Returns the next pseudorandom, uniformly distributed boolean value from the Math.random() sequence.voidnextBytes(byte[] byteArray)Deprecated.Unsupported in 2.0.doublenextDouble()Deprecated.Synonymous to the Math.random() call.floatnextFloat()Deprecated.Returns the next pseudorandom, uniformly distributed float value between0.0and1.0from the Math.random() sequence.doublenextGaussian()Deprecated.Unsupported in 2.0.intnextInt()Deprecated.Returns the next pseudorandom, uniformly distributed int value from the Math.random() sequence.intnextInt(int n)Deprecated.Returns a pseudorandom, uniformly distributed int value between0(inclusive) and the specified value (exclusive), from the Math.random() sequence.longnextLong()Deprecated.Returns the next pseudorandom, uniformly distributed long value from the Math.random() sequence.static longnextLong(long n)Deprecated.Returns a pseudorandom, uniformly distributed long value between0(inclusive) and the specified value (exclusive), from the Math.random() sequence.voidsetSeed(long seed)Deprecated.Unsupported in 2.0. 
 - 
 
- 
- 
Method Detail
- 
setSeed
public void setSeed(long seed)
Deprecated.Unsupported in 2.0.- Overrides:
 setSeedin classjava.util.Random- Parameters:
 seed- ignored- Throws:
 java.lang.UnsupportedOperationException
 
- 
nextGaussian
public double nextGaussian()
Deprecated.Unsupported in 2.0.- Overrides:
 nextGaussianin classjava.util.Random- Returns:
 - Nothing, this method always throws an UnsupportedOperationException.
 - Throws:
 java.lang.UnsupportedOperationException
 
- 
nextBytes
public void nextBytes(byte[] byteArray)
Deprecated.Unsupported in 2.0.- Overrides:
 nextBytesin classjava.util.Random- Parameters:
 byteArray- ignored- Throws:
 java.lang.UnsupportedOperationException
 
- 
nextInt
public int nextInt()
Deprecated.Returns the next pseudorandom, uniformly distributed int value from the Math.random() sequence.
Identical tonextInt(Integer.MAX_VALUE)N.B. All values are >= 0.
- Overrides:
 nextIntin classjava.util.Random- Returns:
 - the random int
 
 
- 
nextInt
public int nextInt(int n)
Deprecated.Returns a pseudorandom, uniformly distributed int value between
0(inclusive) and the specified value (exclusive), from the Math.random() sequence.- Overrides:
 nextIntin classjava.util.Random- Parameters:
 n- the specified exclusive max-value- Returns:
 - the random int
 - Throws:
 java.lang.IllegalArgumentException- whenn <= 0
 
- 
nextLong
public long nextLong()
Deprecated.Returns the next pseudorandom, uniformly distributed long value from the Math.random() sequence.
Identical tonextLong(Long.MAX_VALUE)N.B. All values are >= 0.
- Overrides:
 nextLongin classjava.util.Random- Returns:
 - the random long
 
 
- 
nextLong
public static long nextLong(long n)
Deprecated.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:
 java.lang.IllegalArgumentException- whenn <= 0
 
- 
nextBoolean
public boolean nextBoolean()
Deprecated.Returns the next pseudorandom, uniformly distributed boolean value from the Math.random() sequence.
- Overrides:
 nextBooleanin classjava.util.Random- Returns:
 - the random boolean
 
 
- 
nextFloat
public float nextFloat()
Deprecated.Returns the next pseudorandom, uniformly distributed float value between
0.0and1.0from the Math.random() sequence.- Overrides:
 nextFloatin classjava.util.Random- Returns:
 - the random float
 
 
- 
nextDouble
public double nextDouble()
Deprecated.Synonymous to the Math.random() call.
- Overrides:
 nextDoublein classjava.util.Random- Returns:
 - the random double
 
 
 - 
 
 -