Class JVMRandom
- All Implemented Interfaces:
Serializable,java.util.random.RandomGenerator
JVMRandom is a wrapper that supports all possible
Random methods via the Math.random() method
and its system-wide Random object.
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) and Random.nextLong()
to produce positive numbers ranging from 0 (inclusive)
to MAX_VALUE (exclusive).
- Since:
- 2.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.random.RandomGenerator
java.util.random.RandomGenerator.ArbitrarilyJumpableGenerator, java.util.random.RandomGenerator.JumpableGenerator, java.util.random.RandomGenerator.LeapableGenerator, java.util.random.RandomGenerator.SplittableGenerator, java.util.random.RandomGenerator.StreamableGenerator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.Returns the next pseudorandom, uniformly distributed boolean value from the Math.random() sequence.voidnextBytes(byte[] byteArray) Deprecated.Unsupported in 2.0.doubleDeprecated.Synonymous to the Math.random() call.floatDeprecated.Returns the next pseudorandom, uniformly distributed float value between0.0and1.0from the Math.random() sequence.doubleDeprecated.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.Methods inherited from class java.util.Random
doubles, doubles, doubles, doubles, from, ints, ints, ints, ints, longs, longs, longs, longsMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.random.RandomGenerator
isDeprecated, nextDouble, nextDouble, nextExponential, nextFloat, nextFloat, nextGaussian, nextInt, nextLong, nextLong
-
Constructor Details
-
JVMRandom
public JVMRandom()Deprecated.Constructs a new instance.
-
-
Method Details
-
setSeed
public void setSeed(long seed) Deprecated.Unsupported in 2.0.- Overrides:
setSeedin classRandom- Parameters:
seed- ignored- Throws:
UnsupportedOperationException
-
nextGaussian
public double nextGaussian()Deprecated.Unsupported in 2.0.- Specified by:
nextGaussianin interfacejava.util.random.RandomGenerator- Overrides:
nextGaussianin classRandom- Returns:
- Nothing, this method always throws an UnsupportedOperationException.
- Throws:
UnsupportedOperationException
-
nextBytes
public void nextBytes(byte[] byteArray) Deprecated.Unsupported in 2.0.- Specified by:
nextBytesin interfacejava.util.random.RandomGenerator- Overrides:
nextBytesin classRandom- Parameters:
byteArray- ignored- Throws:
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.
-
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.- Specified by:
nextIntin interfacejava.util.random.RandomGenerator- Overrides:
nextIntin classRandom- Parameters:
n- the specified exclusive max-value- Returns:
- the random int
- Throws:
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.
-
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:
IllegalArgumentException- whenn <= 0
-
nextBoolean
public boolean nextBoolean()Deprecated.Returns the next pseudorandom, uniformly distributed boolean value from the Math.random() sequence.
- Specified by:
nextBooleanin interfacejava.util.random.RandomGenerator- Overrides:
nextBooleanin classRandom- 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. -
nextDouble
public double nextDouble()Deprecated.Synonymous to the Math.random() call.
- Specified by:
nextDoublein interfacejava.util.random.RandomGenerator- Overrides:
nextDoublein classRandom- Returns:
- the random double
-