# RandomGenerator

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Nested Classes](https://developer.android.com/reference/java/util/random/RandomGenerator#nestedclasses)\|[Methods](https://developer.android.com/reference/java/util/random/RandomGenerator#pubmethods)  

# RandomGenerator

`
public


interface
RandomGenerator
`  
`


`

|----------------------------------|
| java.util.random.RandomGenerator |

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known indirect subclasses [Random](https://developer.android.com/reference/java/util/Random),[RandomGenerator.ArbitrarilyJumpableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.ArbitrarilyJumpableGenerator),[RandomGenerator.JumpableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.JumpableGenerator),[RandomGenerator.LeapableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.LeapableGenerator),[RandomGenerator.SplittableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.SplittableGenerator),[RandomGenerator.StreamableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.StreamableGenerator),[SecureRandom](https://developer.android.com/reference/java/security/SecureRandom),[SplittableRandom](https://developer.android.com/reference/java/util/SplittableRandom),[ThreadLocalRandom](https://developer.android.com/reference/java/util/concurrent/ThreadLocalRandom) |-------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Random](https://developer.android.com/reference/java/util/Random)                                                                                    | An instance of this class is used to generate a stream of pseudorandom numbers; its period is only 2^48^.                                                                                                                                                                                                                                                                                     | | [RandomGenerator.ArbitrarilyJumpableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.ArbitrarilyJumpableGenerator) | This interface is designed to provide a common protocol for objects that generate sequences of pseudorandom values and can easily*jump*forward, by an arbitrary amount, to a distant point in the state cycle.                                                                                                                                                                                | | [RandomGenerator.JumpableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.JumpableGenerator)                       | This interface is designed to provide a common protocol for objects that generate pseudorandom values and can easily*jump*forward, by a moderate amount (ex.                                                                                                                                                                                                                                  | | [RandomGenerator.LeapableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.LeapableGenerator)                       | This interface is designed to provide a common protocol for objects that generate sequences of pseudorandom values and can easily not only jump but also*leap*forward, by a large amount (ex.                                                                                                                                                                                                 | | [RandomGenerator.SplittableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.SplittableGenerator)                   | This interface is designed to provide a common protocol for objects that generate sequences of pseudorandom values and can be*split*into two objects (the original one and a new one) each of which obey that same protocol (and therefore can be recursively split indefinitely).                                                                                                            | | [RandomGenerator.StreamableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.StreamableGenerator)                   | The[StreamableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.StreamableGenerator)interface augments the[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator)interface to provide methods that return streams of[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator)objects. | | [SecureRandom](https://developer.android.com/reference/java/security/SecureRandom)                                                                    | This class provides a cryptographically strong random number generator (RNG).                                                                                                                                                                                                                                                                                                                 | | [SplittableRandom](https://developer.android.com/reference/java/util/SplittableRandom)                                                                | A generator of uniform pseudorandom values (with period 2^64^) applicable for use in (among other contexts) isolated parallel computations that may generate subtasks.                                                                                                                                                                                                                        | | [ThreadLocalRandom](https://developer.android.com/reference/java/util/concurrent/ThreadLocalRandom)                                                   | A random number generator (with period 2^64^) isolated to the current thread.                                                                                                                                                                                                                                                                                                                 | |

<br />

*** ** * ** ***

The[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator)interface is designed to provide a common protocol for objects that generate random or (more typically) pseudorandom sequences of numbers (or Boolean values). Such a sequence may be obtained by either repeatedly invoking a method that returns a single pseudorandomly chosen value, or by invoking a method that returns a stream of pseudorandomly chosen values.

Ideally, given an implicitly or explicitly specified range of values, each value would be chosen independently and uniformly from that range. In practice, one may have to settle for some approximation to independence and uniformity.

In the case of`int`,`long`, and`boolean`values, if there is no explicit specification of range, then the range includes all possible values of the type. In the case of`float`and`double`values, first a value is always chosen uniformly from the set of 2^*w*^values between 0.0 (inclusive) and 1.0 (exclusive), where*w* is[Float.PRECISION](https://developer.android.com/reference/java/lang/Float#PRECISION)for`float`values and[Double.PRECISION](https://developer.android.com/reference/java/lang/Double#PRECISION)for`double`values, such that adjacent values differ by 2^−*w*^(notice that this set is a*subset* of the set of*all representable floating-point values*between 0.0 (inclusive) and 1.0 (exclusive)); then if an explicit range was specified, then the chosen number is computationally scaled and translated so as to appear to have been chosen approximately uniformly from that explicit range.

Each method that returns a stream produces a stream of values each of which is chosen in the same manner as for a method that returns a single pseudorandomly chosen value. For example, if`r`implements[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator), then the method call`r.ints(100)`returns a stream of 100`int`values. These are not necessarily the exact same values that would have been returned if instead`r.nextInt()`had been called 100 times; all that is guaranteed is that each value in the stream is chosen in a similar pseudorandom manner from the same range.

Every object that implements the[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator)interface by using a pseudorandom algorithm is assumed to contain a finite amount of state. Using such an object to generate a pseudorandomly chosen value alters its state by computing a new state as a function of the current state, without reference to any information other than the current state. The number of distinct possible states of such an object is called its*period* . (Some implementations of the[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator)interface may be truly random rather than pseudorandom, for example relying on the statistical behavior of a physical object to derive chosen values. Such implementations do not have a fixed period.)

As a rule, objects that implement the[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator)interface need not be thread-safe. It is recommended that multithreaded applications use either[ThreadLocalRandom](https://developer.android.com/reference/java/util/concurrent/ThreadLocalRandom)or (preferably) pseudorandom number generators that implement the[SplittableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.SplittableGenerator)or[JumpableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.JumpableGenerator)interface.

Objects that implement[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator)are typically not cryptographically secure. Consider instead using[SecureRandom](https://developer.android.com/reference/java/security/SecureRandom)to get a cryptographically secure pseudorandom number generator for use by security-sensitive applications. Note, however, that[SecureRandom](https://developer.android.com/reference/java/security/SecureRandom)does implement the[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator)interface, so that instances of[SecureRandom](https://developer.android.com/reference/java/security/SecureRandom)may be used interchangeably with other types of pseudorandom generators in applications that do not require a secure generator.

Unless explicit stated otherwise, the use of null for any method argument will cause a NullPointerException.

## Summary

|                                                                                                                                                                                                                                                               ### Nested classes                                                                                                                                                                                                                                                                ||
|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` interface` | [RandomGenerator.ArbitrarilyJumpableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.ArbitrarilyJumpableGenerator) This interface is designed to provide a common protocol for objects that generate sequences of pseudorandom values and can easily*jump*forward, by an arbitrary amount, to a distant point in the state cycle.                                                                                                                                                              |
| ` interface` | [RandomGenerator.JumpableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.JumpableGenerator) This interface is designed to provide a common protocol for objects that generate pseudorandom values and can easily*jump*forward, by a moderate amount (ex.                                                                                                                                                                                                                                      |
| ` interface` | [RandomGenerator.LeapableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.LeapableGenerator) This interface is designed to provide a common protocol for objects that generate sequences of pseudorandom values and can easily not only jump but also*leap*forward, by a large amount (ex.                                                                                                                                                                                                     |
| ` interface` | [RandomGenerator.SplittableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.SplittableGenerator) This interface is designed to provide a common protocol for objects that generate sequences of pseudorandom values and can be*split*into two objects (the original one and a new one) each of which obey that same protocol (and therefore can be recursively split indefinitely).                                                                                                            |
| ` interface` | [RandomGenerator.StreamableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.StreamableGenerator) The[StreamableGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator.StreamableGenerator)interface augments the[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator)interface to provide methods that return streams of[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator)objects. |

|                                                                                                                                                                                                                                                          ### Public methods                                                                                                                                                                                                                                                           ||
|-------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` default `[DoubleStream](https://developer.android.com/reference/java/util/stream/DoubleStream)      | ` `[doubles](https://developer.android.com/reference/java/util/random/RandomGenerator#doubles(long,%20double,%20double))`(long streamSize, double randomNumberOrigin, double randomNumberBound) ` Returns a stream producing the given`streamSize`number of pseudorandomly chosen`double`values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).                             |
| ` default `[DoubleStream](https://developer.android.com/reference/java/util/stream/DoubleStream)      | ` `[doubles](https://developer.android.com/reference/java/util/random/RandomGenerator#doubles(long))`(long streamSize) ` Returns a stream producing the given`streamSize`number of pseudorandomly chosen`double`values.                                                                                                                                                                                                        |
| ` default `[DoubleStream](https://developer.android.com/reference/java/util/stream/DoubleStream)      | ` `[doubles](https://developer.android.com/reference/java/util/random/RandomGenerator#doubles())`() ` Returns an effectively unlimited stream of pseudorandomly chosen`double`values.                                                                                                                                                                                                                                          |
| ` default `[DoubleStream](https://developer.android.com/reference/java/util/stream/DoubleStream)      | ` `[doubles](https://developer.android.com/reference/java/util/random/RandomGenerator#doubles(double,%20double))`(double randomNumberOrigin, double randomNumberBound) ` Returns an effectively unlimited stream of pseudorandomly chosen`double`values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).                                                                     |
| ` static `[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator) | ` `[getDefault](https://developer.android.com/reference/java/util/random/RandomGenerator#getDefault())`() ` Returns a[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator)meeting the minimal requirement of having an[algorithm](https://developer.android.com/reference/java/util/random/package-summary#algorithms)whose state bits are greater than or equal 64.                     |
| ` default `[IntStream](https://developer.android.com/reference/java/util/stream/IntStream)            | ` `[ints](https://developer.android.com/reference/java/util/random/RandomGenerator#ints(long))`(long streamSize) ` Returns a stream producing the given`streamSize`number of pseudorandomly chosen`int`values.                                                                                                                                                                                                                 |
| ` default `[IntStream](https://developer.android.com/reference/java/util/stream/IntStream)            | ` `[ints](https://developer.android.com/reference/java/util/random/RandomGenerator#ints(int,%20int))`(int randomNumberOrigin, int randomNumberBound) ` Returns an effectively unlimited stream of pseudorandomly chosen`int`values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).                                                                                          |
| ` default `[IntStream](https://developer.android.com/reference/java/util/stream/IntStream)            | ` `[ints](https://developer.android.com/reference/java/util/random/RandomGenerator#ints())`() ` Returns an effectively unlimited stream of pseudorandomly chosen`int`values.                                                                                                                                                                                                                                                   |
| ` default `[IntStream](https://developer.android.com/reference/java/util/stream/IntStream)            | ` `[ints](https://developer.android.com/reference/java/util/random/RandomGenerator#ints(long,%20int,%20int))`(long streamSize, int randomNumberOrigin, int randomNumberBound) ` Returns a stream producing the given`streamSize`number of pseudorandomly chosen`int`values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).                                                  |
| ` default boolean`                                                                                    | ` `[isDeprecated](https://developer.android.com/reference/java/util/random/RandomGenerator#isDeprecated())`() ` Return true if the implementation of RandomGenerator (algorithm) has been marked for deprecation.                                                                                                                                                                                                              |
| ` default `[LongStream](https://developer.android.com/reference/java/util/stream/LongStream)          | ` `[longs](https://developer.android.com/reference/java/util/random/RandomGenerator#longs(long))`(long streamSize) ` Returns a stream producing the given`streamSize`number of pseudorandomly chosen`long`values.                                                                                                                                                                                                              |
| ` default `[LongStream](https://developer.android.com/reference/java/util/stream/LongStream)          | ` `[longs](https://developer.android.com/reference/java/util/random/RandomGenerator#longs())`() ` Returns an effectively unlimited stream of pseudorandomly chosen`long`values.                                                                                                                                                                                                                                                |
| ` default `[LongStream](https://developer.android.com/reference/java/util/stream/LongStream)          | ` `[longs](https://developer.android.com/reference/java/util/random/RandomGenerator#longs(long,%20long))`(long randomNumberOrigin, long randomNumberBound) ` Returns an effectively unlimited stream of pseudorandomly chosen`long`values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).                                                                                   |
| ` default `[LongStream](https://developer.android.com/reference/java/util/stream/LongStream)          | ` `[longs](https://developer.android.com/reference/java/util/random/RandomGenerator#longs(long,%20long,%20long))`(long streamSize, long randomNumberOrigin, long randomNumberBound) ` Returns a stream producing the given`streamSize`number of pseudorandomly chosen`long`values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).                                           |
| ` default boolean`                                                                                    | ` `[nextBoolean](https://developer.android.com/reference/java/util/random/RandomGenerator#nextBoolean())`() ` Returns a pseudorandomly chosen`boolean`value.                                                                                                                                                                                                                                                                   |
| ` default void`                                                                                       | ` `[nextBytes](https://developer.android.com/reference/java/util/random/RandomGenerator#nextBytes(byte[]))`(byte[] bytes) ` Fills a user-supplied byte array with generated byte values pseudorandomly chosen uniformly from the range of values between -128 (inclusive) and 127 (inclusive).                                                                                                                                 |
| ` default double`                                                                                     | ` `[nextDouble](https://developer.android.com/reference/java/util/random/RandomGenerator#nextDouble())`() ` Returns a pseudorandom`double`value between zero (inclusive) and one (exclusive).                                                                                                                                                                                                                                  |
| ` default double`                                                                                     | ` `[nextDouble](https://developer.android.com/reference/java/util/random/RandomGenerator#nextDouble(double))`(double bound) ` Returns a pseudorandomly chosen`double`value between zero (inclusive) and the specified bound (exclusive).                                                                                                                                                                                       |
| ` default double`                                                                                     | ` `[nextDouble](https://developer.android.com/reference/java/util/random/RandomGenerator#nextDouble(double,%20double))`(double origin, double bound) ` Returns a pseudorandomly chosen`double`value between the specified origin (inclusive) and the specified bound (exclusive).                                                                                                                                              |
| ` default double`                                                                                     | ` `[nextExponential](https://developer.android.com/reference/java/util/random/RandomGenerator#nextExponential())`() ` Returns a nonnegative`double`value pseudorandomly chosen from an exponential distribution whose mean is 1.                                                                                                                                                                                               |
| ` default float`                                                                                      | ` `[nextFloat](https://developer.android.com/reference/java/util/random/RandomGenerator#nextFloat(float,%20float))`(float origin, float bound) ` Returns a pseudorandomly chosen`float`value between the specified origin (inclusive) and the specified bound (exclusive).                                                                                                                                                     |
| ` default float`                                                                                      | ` `[nextFloat](https://developer.android.com/reference/java/util/random/RandomGenerator#nextFloat())`() ` Returns a pseudorandom`float`value between zero (inclusive) and one (exclusive).                                                                                                                                                                                                                                     |
| ` default float`                                                                                      | ` `[nextFloat](https://developer.android.com/reference/java/util/random/RandomGenerator#nextFloat(float))`(float bound) ` Returns a pseudorandomly chosen`float`value between zero (inclusive) and the specified bound (exclusive).                                                                                                                                                                                            |
| ` default double`                                                                                     | ` `[nextGaussian](https://developer.android.com/reference/java/util/random/RandomGenerator#nextGaussian(double,%20double))`(double mean, double stddev) ` Returns a`double`value pseudorandomly chosen from a Gaussian (normal) distribution with a mean and standard deviation specified by the arguments.                                                                                                                    |
| ` default double`                                                                                     | ` `[nextGaussian](https://developer.android.com/reference/java/util/random/RandomGenerator#nextGaussian())`() ` Returns a`double`value pseudorandomly chosen from a Gaussian (normal) distribution whose mean is 0 and whose standard deviation is 1.                                                                                                                                                                          |
| ` default int`                                                                                        | ` `[nextInt](https://developer.android.com/reference/java/util/random/RandomGenerator#nextInt(int,%20int))`(int origin, int bound) ` Returns a pseudorandomly chosen`int`value between the specified origin (inclusive) and the specified bound (exclusive).                                                                                                                                                                   |
| ` default int`                                                                                        | ` `[nextInt](https://developer.android.com/reference/java/util/random/RandomGenerator#nextInt())`() ` Returns a pseudorandomly chosen`int`value.                                                                                                                                                                                                                                                                               |
| ` default int`                                                                                        | ` `[nextInt](https://developer.android.com/reference/java/util/random/RandomGenerator#nextInt(int))`(int bound) ` Returns a pseudorandomly chosen`int`value between zero (inclusive) and the specified bound (exclusive).                                                                                                                                                                                                      |
| ` default long`                                                                                       | ` `[nextLong](https://developer.android.com/reference/java/util/random/RandomGenerator#nextLong(long,%20long))`(long origin, long bound) ` Returns a pseudorandomly chosen`long`value between the specified origin (inclusive) and the specified bound (exclusive).                                                                                                                                                            |
| ` default long`                                                                                       | ` `[nextLong](https://developer.android.com/reference/java/util/random/RandomGenerator#nextLong(long))`(long bound) ` Returns a pseudorandomly chosen`long`value between zero (inclusive) and the specified bound (exclusive).                                                                                                                                                                                                 |
| ` abstract long`                                                                                      | ` `[nextLong](https://developer.android.com/reference/java/util/random/RandomGenerator#nextLong())`() ` Returns a pseudorandomly chosen`long`value.                                                                                                                                                                                                                                                                            |
| ` static `[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator) | ` `[of](https://developer.android.com/reference/java/util/random/RandomGenerator#of(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Returns an instance of[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator)that utilizes the`name`[algorithm](https://developer.android.com/reference/java/util/random/package-summary#algorithms). |

## Public methods

### doubles

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DoubleStream doubles (long streamSize, 
                double randomNumberOrigin, 
                double randomNumberBound)
```

Returns a stream producing the given`streamSize`number of pseudorandomly chosen`double`values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).

<br />

##### Implementation Requirements:

- The default implementation produces a sequential stream that repeatedly calls[nextDouble](https://developer.android.com/reference/java/util/random/RandomGenerator#nextDouble(double,%20double))(randomNumberOrigin, randomNumberBound).

|                                         Parameters                                         ||
|----------------------|----------------------------------------------------------------------|
| `streamSize`         | `long`: the number of values to generate <br />                      |
| `randomNumberOrigin` | `double`: the least value that can be produced <br />                |
| `randomNumberBound`  | `double`: the upper bound (exclusive) for each value produced <br /> |

|                                                                                                             Returns                                                                                                              ||
|---------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| [DoubleStream](https://developer.android.com/reference/java/util/stream/DoubleStream) | a stream of pseudorandomly chosen`double`values, each between the specified origin (inclusive) and the specified bound (exclusive) <br /> |

|                                                                                                                                         Throws                                                                                                                                         ||
|--------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`streamSize`is less than zero, or`randomNumberOrigin`is not finite, or`randomNumberBound`is not finite, or`randomNumberOrigin`is greater than or equal to`randomNumberBound` |

### doubles

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DoubleStream doubles (long streamSize)
```

Returns a stream producing the given`streamSize`number of pseudorandomly chosen`double`values.

<br />

##### Implementation Requirements:

- The default implementation produces a sequential stream that repeatedly calls[nextDouble()](https://developer.android.com/reference/java/util/random/RandomGenerator#nextDouble()).

|                          Parameters                           ||
|--------------|-------------------------------------------------|
| `streamSize` | `long`: the number of values to generate <br /> |

|                                                                    Returns                                                                    ||
|---------------------------------------------------------------------------------------|--------------------------------------------------------|
| [DoubleStream](https://developer.android.com/reference/java/util/stream/DoubleStream) | a stream of pseudorandomly chosen`double`values <br /> |

|                                                                 Throws                                                                  ||
|--------------------------------------------------------------------------------------------------------|---------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`streamSize`is less than zero |

### doubles

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DoubleStream doubles ()
```

Returns an effectively unlimited stream of pseudorandomly chosen`double`values.

<br />

##### Implementation Note:

- It is permitted to implement this method in a manner equivalent to[doubles](https://developer.android.com/reference/java/util/random/RandomGenerator#doubles(long))([Long.MAX_VALUE](https://developer.android.com/reference/java/lang/Long#MAX_VALUE)).  

##### Implementation Requirements:

- The default implementation produces a sequential stream that repeatedly calls[nextDouble](https://developer.android.com/reference/java/util/random/RandomGenerator#nextDouble())().

|                                                                    Returns                                                                    ||
|---------------------------------------------------------------------------------------|--------------------------------------------------------|
| [DoubleStream](https://developer.android.com/reference/java/util/stream/DoubleStream) | a stream of pseudorandomly chosen`double`values <br /> |

### doubles

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public DoubleStream doubles (double randomNumberOrigin, 
                double randomNumberBound)
```

Returns an effectively unlimited stream of pseudorandomly chosen`double`values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).

<br />

##### Implementation Note:

- It is permitted to implement this method in a manner equivalent to[doubles](https://developer.android.com/reference/java/util/random/RandomGenerator#doubles(long,%20double,%20double))([Long.MAX_VALUE](https://developer.android.com/reference/java/lang/Long#MAX_VALUE), randomNumberOrigin, randomNumberBound).  

##### Implementation Requirements:

- The default implementation produces a sequential stream that repeatedly calls[nextDouble](https://developer.android.com/reference/java/util/random/RandomGenerator#nextDouble(double,%20double))(randomNumberOrigin, randomNumberBound).

|                                         Parameters                                         ||
|----------------------|----------------------------------------------------------------------|
| `randomNumberOrigin` | `double`: the least value that can be produced <br />                |
| `randomNumberBound`  | `double`: the upper bound (exclusive) for each value produced <br /> |

|                                                                                                             Returns                                                                                                              ||
|---------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| [DoubleStream](https://developer.android.com/reference/java/util/stream/DoubleStream) | a stream of pseudorandomly chosen`double`values, each between the specified origin (inclusive) and the specified bound (exclusive) <br /> |

|                                                                                                                        Throws                                                                                                                         ||
|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`randomNumberOrigin`is not finite, or`randomNumberBound`is not finite, or`randomNumberOrigin`is greater than or equal to`randomNumberBound` |

### getDefault

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static RandomGenerator getDefault ()
```

Returns a[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator)meeting the minimal requirement of having an[algorithm](https://developer.android.com/reference/java/util/random/package-summary#algorithms)whose state bits are greater than or equal 64.

<br />

##### Implementation Requirements:

- Since algorithms will improve over time, there is no guarantee that this method will return the same algorithm over time.The default implementation selects L32X64MixRandom.

|                                                                                             Returns                                                                                              ||
|---------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------|
| [RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator) | a[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator) <br /> |

### ints

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public IntStream ints (long streamSize)
```

Returns a stream producing the given`streamSize`number of pseudorandomly chosen`int`values.

<br />

##### Implementation Requirements:

- The default implementation produces a sequential stream that repeatedly calls[nextInt](https://developer.android.com/reference/java/util/random/RandomGenerator#nextInt())().

|                          Parameters                           ||
|--------------|-------------------------------------------------|
| `streamSize` | `long`: the number of values to generate <br /> |

|                                                               Returns                                                                ||
|---------------------------------------------------------------------------------|-----------------------------------------------------|
| [IntStream](https://developer.android.com/reference/java/util/stream/IntStream) | a stream of pseudorandomly chosen`int`values <br /> |

|                                                                 Throws                                                                  ||
|--------------------------------------------------------------------------------------------------------|---------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`streamSize`is less than zero |

### ints

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public IntStream ints (int randomNumberOrigin, 
                int randomNumberBound)
```

Returns an effectively unlimited stream of pseudorandomly chosen`int`values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).

<br />

##### Implementation Note:

- It is permitted to implement this method in a manner equivalent to[ints](https://developer.android.com/reference/java/util/random/RandomGenerator#ints(long,%20int,%20int))([Long.MAX_VALUE](https://developer.android.com/reference/java/lang/Long#MAX_VALUE), randomNumberOrigin, randomNumberBound).  

##### Implementation Requirements:

- The default implementation produces a sequential stream that repeatedly calls[nextInt](https://developer.android.com/reference/java/util/random/RandomGenerator#nextInt(int,%20int))(randomNumberOrigin, randomNumberBound).

|                                       Parameters                                        ||
|----------------------|-------------------------------------------------------------------|
| `randomNumberOrigin` | `int`: the least value that can be produced <br />                |
| `randomNumberBound`  | `int`: the upper bound (exclusive) for each value produced <br /> |

|                                                                                                         Returns                                                                                                         ||
|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| [IntStream](https://developer.android.com/reference/java/util/stream/IntStream) | a stream of pseudorandomly chosen`int`values, each between the specified origin (inclusive) and the specified bound (exclusive) <br /> |

|                                                                                    Throws                                                                                    ||
|--------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`randomNumberOrigin`is greater than or equal to`randomNumberBound` |

### ints

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public IntStream ints ()
```

Returns an effectively unlimited stream of pseudorandomly chosen`int`values.

<br />

##### Implementation Note:

- It is permitted to implement this method in a manner equivalent to[ints](https://developer.android.com/reference/java/util/random/RandomGenerator#ints(long))([Long.MAX_VALUE](https://developer.android.com/reference/java/lang/Long#MAX_VALUE)).  

##### Implementation Requirements:

- The default implementation produces a sequential stream that repeatedly calls[nextInt](https://developer.android.com/reference/java/util/random/RandomGenerator#nextInt())().

|                                                               Returns                                                                ||
|---------------------------------------------------------------------------------|-----------------------------------------------------|
| [IntStream](https://developer.android.com/reference/java/util/stream/IntStream) | a stream of pseudorandomly chosen`int`values <br /> |

### ints

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public IntStream ints (long streamSize, 
                int randomNumberOrigin, 
                int randomNumberBound)
```

Returns a stream producing the given`streamSize`number of pseudorandomly chosen`int`values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).

<br />

##### Implementation Requirements:

- The default implementation produces a sequential stream that repeatedly calls[nextInt](https://developer.android.com/reference/java/util/random/RandomGenerator#nextInt(int,%20int))(randomNumberOrigin, randomNumberBound).

|                                       Parameters                                        ||
|----------------------|-------------------------------------------------------------------|
| `streamSize`         | `long`: the number of values to generate <br />                   |
| `randomNumberOrigin` | `int`: the least value that can be produced <br />                |
| `randomNumberBound`  | `int`: the upper bound (exclusive) for each value produced <br /> |

|                                                                                                         Returns                                                                                                         ||
|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| [IntStream](https://developer.android.com/reference/java/util/stream/IntStream) | a stream of pseudorandomly chosen`int`values, each between the specified origin (inclusive) and the specified bound (exclusive) <br /> |

|                                                                                                    Throws                                                                                                     ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`streamSize`is less than zero, or`randomNumberOrigin`is greater than or equal to`randomNumberBound` |

### isDeprecated

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean isDeprecated ()
```

Return true if the implementation of RandomGenerator (algorithm) has been marked for deprecation.

<br />

##### Implementation Note:

- Random number generator algorithms evolve over time; new algorithms will be introduced and old algorithms will lose standing. If an older algorithm is deemed unsuitable for continued use, it will be marked as deprecated to indicate that it may be removed at some point in the future.  

##### Implementation Requirements:

- The default implementation checks for the @Deprecated annotation.

|                                                   Returns                                                   ||
|-----------|--------------------------------------------------------------------------------------------------|
| `boolean` | true if the implementation of RandomGenerator (algorithm) has been marked for deprecation <br /> |

### longs

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LongStream longs (long streamSize)
```

Returns a stream producing the given`streamSize`number of pseudorandomly chosen`long`values.

<br />

##### Implementation Requirements:

- The default implementation produces a sequential stream that repeatedly calls[nextLong](https://developer.android.com/reference/java/util/random/RandomGenerator#nextLong())().

|                          Parameters                           ||
|--------------|-------------------------------------------------|
| `streamSize` | `long`: the number of values to generate <br /> |

|                                                                 Returns                                                                 ||
|-----------------------------------------------------------------------------------|------------------------------------------------------|
| [LongStream](https://developer.android.com/reference/java/util/stream/LongStream) | a stream of pseudorandomly chosen`long`values <br /> |

|                                                                 Throws                                                                  ||
|--------------------------------------------------------------------------------------------------------|---------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`streamSize`is less than zero |

### longs

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LongStream longs ()
```

Returns an effectively unlimited stream of pseudorandomly chosen`long`values.

<br />

##### Implementation Note:

- It is permitted to implement this method in a manner equivalent to[longs](https://developer.android.com/reference/java/util/random/RandomGenerator#longs(long))([Long.MAX_VALUE](https://developer.android.com/reference/java/lang/Long#MAX_VALUE)).  

##### Implementation Requirements:

- The default implementation produces a sequential stream that repeatedly calls[nextLong](https://developer.android.com/reference/java/util/random/RandomGenerator#nextLong())().

|                                                                 Returns                                                                 ||
|-----------------------------------------------------------------------------------|------------------------------------------------------|
| [LongStream](https://developer.android.com/reference/java/util/stream/LongStream) | a stream of pseudorandomly chosen`long`values <br /> |

### longs

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LongStream longs (long randomNumberOrigin, 
                long randomNumberBound)
```

Returns an effectively unlimited stream of pseudorandomly chosen`long`values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).

<br />

##### Implementation Note:

- It is permitted to implement this method in a manner equivalent to[longs](https://developer.android.com/reference/java/util/random/RandomGenerator#longs(long,%20long,%20long))([Long.MAX_VALUE](https://developer.android.com/reference/java/lang/Long#MAX_VALUE), randomNumberOrigin, randomNumberBound).  

##### Implementation Requirements:

- The default implementation produces a sequential stream that repeatedly calls[nextLong](https://developer.android.com/reference/java/util/random/RandomGenerator#nextLong(long,%20long))(randomNumberOrigin, randomNumberBound).

|                                        Parameters                                        ||
|----------------------|--------------------------------------------------------------------|
| `randomNumberOrigin` | `long`: the least value that can be produced <br />                |
| `randomNumberBound`  | `long`: the upper bound (exclusive) for each value produced <br /> |

|                                                                                                          Returns                                                                                                           ||
|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| [LongStream](https://developer.android.com/reference/java/util/stream/LongStream) | a stream of pseudorandomly chosen`long`values, each between the specified origin (inclusive) and the specified bound (exclusive) <br /> |

|                                                                                    Throws                                                                                    ||
|--------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`randomNumberOrigin`is greater than or equal to`randomNumberBound` |

### longs

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LongStream longs (long streamSize, 
                long randomNumberOrigin, 
                long randomNumberBound)
```

Returns a stream producing the given`streamSize`number of pseudorandomly chosen`long`values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).

<br />

##### Implementation Requirements:

- The default implementation produces a sequential stream that repeatedly calls[nextLong](https://developer.android.com/reference/java/util/random/RandomGenerator#nextLong(long,%20long))(randomNumberOrigin, randomNumberBound).

|                                        Parameters                                        ||
|----------------------|--------------------------------------------------------------------|
| `streamSize`         | `long`: the number of values to generate <br />                    |
| `randomNumberOrigin` | `long`: the least value that can be produced <br />                |
| `randomNumberBound`  | `long`: the upper bound (exclusive) for each value produced <br /> |

|                                                                                                          Returns                                                                                                           ||
|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| [LongStream](https://developer.android.com/reference/java/util/stream/LongStream) | a stream of pseudorandomly chosen`long`values, each between the specified origin (inclusive) and the specified bound (exclusive) <br /> |

|                                                                                                    Throws                                                                                                     ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`streamSize`is less than zero, or`randomNumberOrigin`is greater than or equal to`randomNumberBound` |

### nextBoolean

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean nextBoolean ()
```

Returns a pseudorandomly chosen`boolean`value.

The default implementation tests the high-order bit (sign bit) of a value produced by[nextInt](https://developer.android.com/reference/java/util/random/RandomGenerator#nextInt())(), on the grounds that some algorithms for pseudorandom number generation produce values whose high-order bits have better statistical quality than the low-order bits.

<br />

##### Implementation Requirements:

- The default implementation produces a result based on the sign bit of a number generated by[nextInt()](https://developer.android.com/reference/java/util/random/RandomGenerator#nextInt()).

|                         Returns                         ||
|-----------|----------------------------------------------|
| `boolean` | a pseudorandomly chosen`boolean`value <br /> |

### nextBytes

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void nextBytes (byte[] bytes)
```

Fills a user-supplied byte array with generated byte values pseudorandomly chosen uniformly from the range of values between -128 (inclusive) and 127 (inclusive).

<br />

##### Implementation Note:

- Algorithm used to fill the byte array;  

      void nextBytes(byte[] bytes) {
                     int i = 0;
                     int len = bytes.length;
                     for (int words = len >> 3; words--> 0; ) {
                         long rnd = nextLong();
                         for (int n = 8; n--> 0; rnd >>>= Byte.SIZE)
                             bytes[i++] = (byte)rnd;
                     }
                     if (i < len)
                         for (long rnd = nextLong(); i < len; rnd >>>= Byte.SIZE)
                             bytes[i++] = (byte)rnd;
                 }

##### Implementation Requirements:

- The default implementation produces results from repeated calls to[nextLong()](https://developer.android.com/reference/java/util/random/RandomGenerator#nextLong()).

|                               Parameters                               ||
|---------|---------------------------------------------------------------|
| `bytes` | `byte`: the byte array to fill with pseudorandom bytes <br /> |

|                                                      Throws                                                      ||
|------------------------------------------------------------------------------------------------|------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException) | if bytes is null |

### nextDouble

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public double nextDouble ()
```

Returns a pseudorandom`double`value between zero (inclusive) and one (exclusive).

<br />

##### Implementation Requirements:

- The default implementation uses the[Double.PRECISION](https://developer.android.com/reference/java/lang/Double#PRECISION)high-order bits from a call to[nextLong()](https://developer.android.com/reference/java/util/random/RandomGenerator#nextLong()).

|                                          Returns                                          ||
|----------|---------------------------------------------------------------------------------|
| `double` | a pseudorandom`double`value between zero (inclusive) and one (exclusive) <br /> |

### nextDouble

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public double nextDouble (double bound)
```

Returns a pseudorandomly chosen`double`value between zero (inclusive) and the specified bound (exclusive).

<br />

##### Implementation Requirements:

- The default implementation checks that`bound`is a positive finite double. Then invokes`nextDouble()`, scaling the result so that the final result lies between`0.0`(inclusive) and`bound`(exclusive).

|                                                Parameters                                                 ||
|---------|--------------------------------------------------------------------------------------------------|
| `bound` | `double`: the upper bound (exclusive) for the returned value. Must be positive and finite <br /> |

|                                                 Returns                                                  ||
|----------|------------------------------------------------------------------------------------------------|
| `double` | a pseudorandomly chosen`double`value between zero (inclusive) and the bound (exclusive) <br /> |

|                                                                      Throws                                                                      ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`bound`is not both positive and finite |

### nextDouble

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public double nextDouble (double origin, 
                double bound)
```

Returns a pseudorandomly chosen`double`value between the specified origin (inclusive) and the specified bound (exclusive).

<br />

##### Implementation Requirements:

- The default implementation verifies that the`origin`and`bound`are valid, then invokes`nextDouble()`scaling and translating the result to fit between`origin`and`bound`( exclusive).

|                                  Parameters                                   ||
|----------|---------------------------------------------------------------------|
| `origin` | `double`: the least value that can be returned <br />               |
| `bound`  | `double`: the upper bound (exclusive) for the returned value <br /> |

|                                                    Returns                                                     ||
|----------|------------------------------------------------------------------------------------------------------|
| `double` | a pseudorandomly chosen`double`value between the origin (inclusive) and the bound (exclusive) <br /> |

|                                                                                                Throws                                                                                                 ||
|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`origin`is not finite, or`bound`is not finite, or`origin`is greater than or equal to`bound` |

### nextExponential

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public double nextExponential ()
```

Returns a nonnegative`double`value pseudorandomly chosen from an exponential distribution whose mean is 1.

<br />

##### Implementation Requirements:

- The default implementation uses McFarland's fast modified ziggurat algorithm (largely table-driven, with rare cases handled by computation and rejection sampling). Walker's alias method for sampling a discrete distribution also plays a role.

|                                              Returns                                               ||
|----------|------------------------------------------------------------------------------------------|
| `double` | a nonnegative`double`value pseudorandomly chosen from an exponential distribution <br /> |

### nextFloat

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public float nextFloat (float origin, 
                float bound)
```

Returns a pseudorandomly chosen`float`value between the specified origin (inclusive) and the specified bound (exclusive).

<br />

##### Implementation Requirements:

- The default implementation verifies that the`origin`and`bound`are valid then invokes`nextFloat()`scaling and translating the result to fit between`origin`and`bound`(exclusive).

|                           Parameters                           ||
|----------|------------------------------------------------------|
| `origin` | `float`: the least value that can be returned <br /> |
| `bound`  | `float`: the upper bound (exclusive) <br />          |

|                                                   Returns                                                    ||
|---------|-----------------------------------------------------------------------------------------------------|
| `float` | a pseudorandomly chosen`float`value between the origin (inclusive) and the bound (exclusive) <br /> |

|                                                                                                Throws                                                                                                 ||
|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`origin`is not finite, or`bound`is not finite, or`origin`is greater than or equal to`bound` |

### nextFloat

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public float nextFloat ()
```

Returns a pseudorandom`float`value between zero (inclusive) and one (exclusive).

<br />

##### Implementation Requirements:

- The default implementation uses the[Float.PRECISION](https://developer.android.com/reference/java/lang/Float#PRECISION)high-order bits from a call to[nextInt()](https://developer.android.com/reference/java/util/random/RandomGenerator#nextInt()).

|                                         Returns                                         ||
|---------|--------------------------------------------------------------------------------|
| `float` | a pseudorandom`float`value between zero (inclusive) and one (exclusive) <br /> |

### nextFloat

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public float nextFloat (float bound)
```

Returns a pseudorandomly chosen`float`value between zero (inclusive) and the specified bound (exclusive).

<br />

##### Implementation Requirements:

- The default implementation checks that`bound`is a positive finite float. Then invokes`nextFloat()`, scaling the result so that the final result lies between`0.0f`(inclusive) and`bound`(exclusive).

|                                                Parameters                                                ||
|---------|-------------------------------------------------------------------------------------------------|
| `bound` | `float`: the upper bound (exclusive) for the returned value. Must be positive and finite <br /> |

|                                                Returns                                                 ||
|---------|-----------------------------------------------------------------------------------------------|
| `float` | a pseudorandomly chosen`float`value between zero (inclusive) and the bound (exclusive) <br /> |

|                                                                      Throws                                                                      ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`bound`is not both positive and finite |

### nextGaussian

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public double nextGaussian (double mean, 
                double stddev)
```

Returns a`double`value pseudorandomly chosen from a Gaussian (normal) distribution with a mean and standard deviation specified by the arguments.

<br />

##### Implementation Requirements:

- The default implementation uses McFarland's fast modified ziggurat algorithm (largely table-driven, with rare cases handled by computation and rejection sampling). Walker's alias method for sampling a discrete distribution also plays a role.

|                                                          Parameters                                                           ||
|----------|---------------------------------------------------------------------------------------------------------------------|
| `mean`   | `double`: the mean of the Gaussian distribution to be drawn from <br />                                             |
| `stddev` | `double`: the standard deviation (square root of the variance) of the Gaussian distribution to be drawn from <br /> |

|                                            Returns                                             ||
|----------|--------------------------------------------------------------------------------------|
| `double` | a`double`value pseudorandomly chosen from the specified Gaussian distribution <br /> |

|                                                            Throws                                                             ||
|--------------------------------------------------------------------------------------------------------|-----------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`stddev`is negative |

### nextGaussian

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public double nextGaussian ()
```

Returns a`double`value pseudorandomly chosen from a Gaussian (normal) distribution whose mean is 0 and whose standard deviation is 1.

<br />

##### Implementation Requirements:

- The default implementation uses McFarland's fast modified ziggurat algorithm (largely table-driven, with rare cases handled by computation and rejection sampling). Walker's alias method for sampling a discrete distribution also plays a role.

|                                      Returns                                       ||
|----------|--------------------------------------------------------------------------|
| `double` | a`double`value pseudorandomly chosen from a Gaussian distribution <br /> |

### nextInt

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int nextInt (int origin, 
                int bound)
```

Returns a pseudorandomly chosen`int`value between the specified origin (inclusive) and the specified bound (exclusive).

<br />

##### Implementation Requirements:

- The default implementation checks that`origin`is less than`bound`. It then invokes[nextInt()](https://developer.android.com/reference/java/util/random/RandomGenerator#nextInt())one or more times to ensure a uniform distribution in the range`origin`(inclusive) to`bound`(exclusive). It assumes the distribution of[nextInt()](https://developer.android.com/reference/java/util/random/RandomGenerator#nextInt())to be uniform.

|                                 Parameters                                 ||
|----------|------------------------------------------------------------------|
| `origin` | `int`: the least value that can be returned <br />               |
| `bound`  | `int`: the upper bound (exclusive) for the returned value <br /> |

|                                                 Returns                                                  ||
|-------|---------------------------------------------------------------------------------------------------|
| `int` | a pseudorandomly chosen`int`value between the origin (inclusive) and the bound (exclusive) <br /> |

|                                                                        Throws                                                                        ||
|--------------------------------------------------------------------------------------------------------|----------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`origin`is greater than or equal to`bound` |

### nextInt

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int nextInt ()
```

Returns a pseudorandomly chosen`int`value.

<br />

##### Implementation Requirements:

- The default implementation uses the 32 high-order bits from a call to[nextLong](https://developer.android.com/reference/java/util/random/RandomGenerator#nextLong())().

|                     Returns                     ||
|-------|------------------------------------------|
| `int` | a pseudorandomly chosen`int`value <br /> |

### nextInt

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int nextInt (int bound)
```

Returns a pseudorandomly chosen`int`value between zero (inclusive) and the specified bound (exclusive).

<br />

##### Implementation Requirements:

- The default implementation checks that`bound`is positive. It then invokes[nextInt()](https://developer.android.com/reference/java/util/random/RandomGenerator#nextInt())one or more times to ensure a uniform distribution in the range 0 (inclusive) to`bound`(exclusive). It assumes the distribution of[nextInt()](https://developer.android.com/reference/java/util/random/RandomGenerator#nextInt())to be uniform.

|                                          Parameters                                          ||
|---------|-------------------------------------------------------------------------------------|
| `bound` | `int`: the upper bound (exclusive) for the returned value. Must be positive. <br /> |

|                                              Returns                                               ||
|-------|---------------------------------------------------------------------------------------------|
| `int` | a pseudorandomly chosen`int`value between zero (inclusive) and the bound (exclusive) <br /> |

|                                                              Throws                                                              ||
|--------------------------------------------------------------------------------------------------------|--------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`bound`is not positive |

### nextLong

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long nextLong (long origin, 
                long bound)
```

Returns a pseudorandomly chosen`long`value between the specified origin (inclusive) and the specified bound (exclusive).

<br />

##### Implementation Requirements:

- The default implementation checks that`origin`is less than`bound`. It then invokes[nextLong()](https://developer.android.com/reference/java/util/random/RandomGenerator#nextLong())one or more times to ensure a uniform distribution in the range`origin`(inclusive) to`bound`(exclusive). It assumes the distribution of[nextLong()](https://developer.android.com/reference/java/util/random/RandomGenerator#nextLong())to be uniform.

|                                 Parameters                                  ||
|----------|-------------------------------------------------------------------|
| `origin` | `long`: the least value that can be returned <br />               |
| `bound`  | `long`: the upper bound (exclusive) for the returned value <br /> |

|                                                  Returns                                                   ||
|--------|----------------------------------------------------------------------------------------------------|
| `long` | a pseudorandomly chosen`long`value between the origin (inclusive) and the bound (exclusive) <br /> |

|                                                                        Throws                                                                        ||
|--------------------------------------------------------------------------------------------------------|----------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`origin`is greater than or equal to`bound` |

### nextLong

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long nextLong (long bound)
```

Returns a pseudorandomly chosen`long`value between zero (inclusive) and the specified bound (exclusive).

<br />

##### Implementation Requirements:

- The default implementation checks that`bound`is positive. It then invokes[nextLong()](https://developer.android.com/reference/java/util/random/RandomGenerator#nextLong())one or more times to ensure a uniform distribution in the range 0 (inclusive) to`bound`(exclusive). It assumes the distribution of[nextLong()](https://developer.android.com/reference/java/util/random/RandomGenerator#nextLong())to be uniform.

|                                          Parameters                                           ||
|---------|--------------------------------------------------------------------------------------|
| `bound` | `long`: the upper bound (exclusive) for the returned value. Must be positive. <br /> |

|                                               Returns                                                ||
|--------|----------------------------------------------------------------------------------------------|
| `long` | a pseudorandomly chosen`long`value between zero (inclusive) and the bound (exclusive) <br /> |

|                                                              Throws                                                              ||
|--------------------------------------------------------------------------------------------------------|--------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`bound`is not positive |

### nextLong

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract long nextLong ()
```

Returns a pseudorandomly chosen`long`value.

<br />

|                      Returns                      ||
|--------|-------------------------------------------|
| `long` | a pseudorandomly chosen`long`value <br /> |

### of

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static RandomGenerator of (String name)
```

Returns an instance of[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator)that utilizes the`name`[algorithm](https://developer.android.com/reference/java/util/random/package-summary#algorithms).

<br />

|                                                                        Parameters                                                                        ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| `name` | `String`: Name of random number generator[algorithm](https://developer.android.com/reference/java/util/random/package-summary#algorithms) <br /> |

|                                                                                                    Returns                                                                                                    ||
|---------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
| [RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator) | An instance of[RandomGenerator](https://developer.android.com/reference/java/util/random/RandomGenerator) <br /> |

|                                                                   Throws                                                                    ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------|
| [NullPointerException](https://developer.android.com/reference/java/lang/NullPointerException)         | if name is null                     |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the named algorithm is not found |