JVMRandom (Lang 2.6)
Date: 2019-09-02

org.apache.commons.lang.math

## Class JVMRandom

- java.lang.Object
- - java.util.Random
  - - org.apache.commons.lang.math.JVMRandom

- All Implemented Interfaces:
    java.io.Serializable

      public final class JVMRandom
      extends java.util.Random

  `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
  Version:
    $Id: JVMRandom.java 911986 2010-02-19 21:19:05Z niallp $
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `JVMRandom()` Constructs a new instance.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `nextBoolean()` Returns the next pseudorandom, uniformly distributed boolean value from the Math.random() sequence.
    `void` | `nextBytes(byte[] byteArray)` Unsupported in 2.0.
    `double` | `nextDouble()` Synonymous to the Math.random() call.
    `float` | `nextFloat()` Returns the next pseudorandom, uniformly distributed float value between `0.0` and `1.0` from the Math.random() sequence.
    `double` | `nextGaussian()` Unsupported in 2.0.
    `int` | `nextInt()` Returns the next pseudorandom, uniformly distributed int value from the Math.random() sequence.
    `int` | `nextInt(int n)` Returns a pseudorandom, uniformly distributed int value between `0` (inclusive) and the specified value (exclusive), from the Math.random() sequence.
    `long` | `nextLong()` Returns the next pseudorandom, uniformly distributed long value from the Math.random() sequence.
    `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.
    `void` | `setSeed(long seed)` Unsupported in 2.0.

    - ### Methods inherited from class java.util.Random

      `doubles, doubles, doubles, doubles, ints, ints, ints, ints, longs, longs, longs, longs, next`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### JVMRandom

          public JVMRandom()

      Constructs a new instance.

  - ### Method Detail

    - #### setSeed

          public void setSeed(long seed)

      Unsupported in 2.0.
      Overrides:
        `setSeed` in class `java.util.Random`
      Parameters:
        `seed` - ignored
      Throws:
        `java.lang.UnsupportedOperationException`

    - #### nextGaussian

          public double nextGaussian()

      Unsupported in 2.0.
      Overrides:
        `nextGaussian` in class `java.util.Random`
      Returns:
        Nothing, this method always throws an UnsupportedOperationException.
      Throws:
        `java.lang.UnsupportedOperationException`

    - #### nextBytes

          public void nextBytes(byte[] byteArray)

      Unsupported in 2.0.
      Overrides:
        `nextBytes` in class `java.util.Random`
      Parameters:
        `byteArray` - ignored
      Throws:
        `java.lang.UnsupportedOperationException`

    - #### nextInt

          public int nextInt()

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

      Identical to `nextInt(Integer.MAX_VALUE)`

      N.B. All values are >= 0.

      Overrides:
        `nextInt` in class `java.util.Random`
      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.

      Overrides:
        `nextInt` in class `java.util.Random`
      Parameters:
        `n` - the specified exclusive max-value
      Returns:
        the random int
      Throws:
        `java.lang.IllegalArgumentException` - when `n <= 0`

    - #### nextLong

          public long nextLong()

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

      Identical to `nextLong(Long.MAX_VALUE)`

      N.B. All values are >= 0.

      Overrides:
        `nextLong` in class `java.util.Random`
      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:
        `java.lang.IllegalArgumentException` - when `n <= 0`

    - #### nextBoolean

          public boolean nextBoolean()

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

      Overrides:
        `nextBoolean` in class `java.util.Random`
      Returns:
        the random boolean

    - #### nextFloat

          public float nextFloat()

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

      Overrides:
        `nextFloat` in class `java.util.Random`
      Returns:
        the random float

    - #### nextDouble

          public double nextDouble()

      Synonymous to the Math.random() call.

      Overrides:
        `nextDouble` in class `java.util.Random`
      Returns:
        the random double

Copyright © 2001-2019 - Apache Software Foundation