public final class SplittableRandom extends Object
SplittableRandom supports methods for
 producing pseudorandom numbers of type int, long,
 and double with similar usages as for class
 Random but differs in the following ways:
 split() constructs and returns a new
 SplittableRandom instance that shares no mutable state with the
 current instance. However, with very high probability, the
 values collectively generated by the two objects have the same
 statistical properties as if the same quantity of values were
 generated by a single thread using a single SplittableRandom object.  fork/join-style computation using random numbers might include a
 construction of the form new
 Subtask(aSplittableRandom.split()).fork().
 stream.parallel() mode.Instances of SplittableRandom are not cryptographically
 secure.  Consider instead using SecureRandom
 in security-sensitive applications. Additionally,
 default-constructed instances do not use a cryptographically random
 seed unless the system property
 java.util.secureRandomSeed is set to true.
| Constructor and Description | 
|---|
| SplittableRandom()Creates a new SplittableRandom instance that is likely to
 generate sequences of values that are statistically independent
 of those of any other instances in the current program; and
 may, and typically does, vary across program invocations. | 
| SplittableRandom(long seed)Creates a new SplittableRandom instance using the specified
 initial seed. | 
| Modifier and Type | Method and Description | 
|---|---|
| DoubleStream | doubles()Returns an effectively unlimited stream of pseudorandom  doublevalues from this generator and/or one split from it; each value
 is between zero (inclusive) and one (exclusive). | 
| DoubleStream | doubles(double randomNumberOrigin,
       double randomNumberBound)Returns an effectively unlimited stream of pseudorandom  doublevalues from this generator and/or one split from it; each value
 conforms to the given origin (inclusive) and bound (exclusive). | 
| DoubleStream | doubles(long streamSize)Returns a stream producing the given  streamSizenumber of
 pseudorandomdoublevalues from this generator and/or one split
 from it; each value is between zero (inclusive) and one (exclusive). | 
| DoubleStream | doubles(long streamSize,
       double randomNumberOrigin,
       double randomNumberBound)Returns a stream producing the given  streamSizenumber of
 pseudorandomdoublevalues from this generator and/or one split
 from it; each value conforms to the given origin (inclusive) and bound
 (exclusive). | 
| IntStream | ints()Returns an effectively unlimited stream of pseudorandom  intvalues from this generator and/or one split from it. | 
| IntStream | ints(int randomNumberOrigin,
    int randomNumberBound)Returns an effectively unlimited stream of pseudorandom  intvalues from this generator and/or one split from it; each value
 conforms to the given origin (inclusive) and bound (exclusive). | 
| IntStream | ints(long streamSize)Returns a stream producing the given  streamSizenumber
 of pseudorandomintvalues from this generator and/or
 one split from it. | 
| IntStream | ints(long streamSize,
    int randomNumberOrigin,
    int randomNumberBound)Returns a stream producing the given  streamSizenumber
 of pseudorandomintvalues from this generator and/or one split
 from it; each value conforms to the given origin (inclusive) and bound
 (exclusive). | 
| LongStream | longs()Returns an effectively unlimited stream of pseudorandom  longvalues from this generator and/or one split from it. | 
| LongStream | longs(long streamSize)Returns a stream producing the given  streamSizenumber
 of pseudorandomlongvalues from this generator and/or
 one split from it. | 
| LongStream | longs(long randomNumberOrigin,
     long randomNumberBound)Returns an effectively unlimited stream of pseudorandom  longvalues from this generator and/or one split from it; each value
 conforms to the given origin (inclusive) and bound (exclusive). | 
| LongStream | longs(long streamSize,
     long randomNumberOrigin,
     long randomNumberBound)Returns a stream producing the given  streamSizenumber of
 pseudorandomlongvalues from this generator and/or one split
 from it; each value conforms to the given origin (inclusive) and bound
 (exclusive). | 
| boolean | nextBoolean()Returns a pseudorandom  booleanvalue. | 
| double | nextDouble()Returns a pseudorandom  doublevalue between zero
 (inclusive) and one (exclusive). | 
| double | nextDouble(double bound)Returns a pseudorandom  doublevalue between 0.0
 (inclusive) and the specified bound (exclusive). | 
| double | nextDouble(double origin,
          double bound)Returns a pseudorandom  doublevalue between the specified
 origin (inclusive) and bound (exclusive). | 
| int | nextInt()Returns a pseudorandom  intvalue. | 
| int | nextInt(int bound)Returns a pseudorandom  intvalue between zero (inclusive)
 and the specified bound (exclusive). | 
| int | nextInt(int origin,
       int bound)Returns a pseudorandom  intvalue between the specified
 origin (inclusive) and the specified bound (exclusive). | 
| long | nextLong()Returns a pseudorandom  longvalue. | 
| long | nextLong(long bound)Returns a pseudorandom  longvalue between zero (inclusive)
 and the specified bound (exclusive). | 
| long | nextLong(long origin,
        long bound)Returns a pseudorandom  longvalue between the specified
 origin (inclusive) and the specified bound (exclusive). | 
| SplittableRandom | split()Constructs and returns a new SplittableRandom instance that
 shares no mutable state with this instance. | 
public SplittableRandom(long seed)
seed - the initial seedpublic SplittableRandom()
public SplittableRandom split()
split() method,
 and the same expected statistical properties apply to the
 entire set of generators constructed by such recursive
 splitting.public int nextInt()
int value.int valuepublic int nextInt(int bound)
int value between zero (inclusive)
 and the specified bound (exclusive).bound - the upper bound (exclusive).  Must be positive.int value between zero
         (inclusive) and the bound (exclusive)IllegalArgumentException - if bound is not positivepublic int nextInt(int origin,
                   int bound)
int value between the specified
 origin (inclusive) and the specified bound (exclusive).origin - the least value returnedbound - the upper bound (exclusive)int value between the origin
         (inclusive) and the bound (exclusive)IllegalArgumentException - if origin is greater than
         or equal to boundpublic long nextLong()
long value.long valuepublic long nextLong(long bound)
long value between zero (inclusive)
 and the specified bound (exclusive).bound - the upper bound (exclusive).  Must be positive.long value between zero
         (inclusive) and the bound (exclusive)IllegalArgumentException - if bound is not positivepublic long nextLong(long origin,
                     long bound)
long value between the specified
 origin (inclusive) and the specified bound (exclusive).origin - the least value returnedbound - the upper bound (exclusive)long value between the origin
         (inclusive) and the bound (exclusive)IllegalArgumentException - if origin is greater than
         or equal to boundpublic double nextDouble()
double value between zero
 (inclusive) and one (exclusive).double value between zero
         (inclusive) and one (exclusive)public double nextDouble(double bound)
double value between 0.0
 (inclusive) and the specified bound (exclusive).bound - the upper bound (exclusive).  Must be positive.double value between zero
         (inclusive) and the bound (exclusive)IllegalArgumentException - if bound is not positivepublic double nextDouble(double origin,
                         double bound)
double value between the specified
 origin (inclusive) and bound (exclusive).origin - the least value returnedbound - the upper bound (exclusive)double value between the origin
         (inclusive) and the bound (exclusive)IllegalArgumentException - if origin is greater than
         or equal to boundpublic boolean nextBoolean()
boolean value.boolean valuepublic IntStream ints(long streamSize)
streamSize number
 of pseudorandom int values from this generator and/or
 one split from it.streamSize - the number of values to generateint valuesIllegalArgumentException - if streamSize is
         less than zeropublic IntStream ints()
int
 values from this generator and/or one split from it.ints(Long.MAX_VALUE).int valuespublic IntStream ints(long streamSize, int randomNumberOrigin, int randomNumberBound)
streamSize number
 of pseudorandom int values from this generator and/or one split
 from it; each value conforms to the given origin (inclusive) and bound
 (exclusive).streamSize - the number of values to generaterandomNumberOrigin - the origin (inclusive) of each random valuerandomNumberBound - the bound (exclusive) of each random valueint values,
         each with the given origin (inclusive) and bound (exclusive)IllegalArgumentException - if streamSize is
         less than zero, or randomNumberOrigin
         is greater than or equal to randomNumberBoundpublic IntStream ints(int randomNumberOrigin, int randomNumberBound)
int values from this generator and/or one split from it; each value
 conforms to the given origin (inclusive) and bound (exclusive).ints(Long.MAX_VALUE, randomNumberOrigin, randomNumberBound).randomNumberOrigin - the origin (inclusive) of each random valuerandomNumberBound - the bound (exclusive) of each random valueint values,
         each with the given origin (inclusive) and bound (exclusive)IllegalArgumentException - if randomNumberOrigin
         is greater than or equal to randomNumberBoundpublic LongStream longs(long streamSize)
streamSize number
 of pseudorandom long values from this generator and/or
 one split from it.streamSize - the number of values to generatelong valuesIllegalArgumentException - if streamSize is
         less than zeropublic LongStream longs()
long values from this generator and/or one split from it.longs(Long.MAX_VALUE).long valuespublic LongStream longs(long streamSize, long randomNumberOrigin, long randomNumberBound)
streamSize number of
 pseudorandom long values from this generator and/or one split
 from it; each value conforms to the given origin (inclusive) and bound
 (exclusive).streamSize - the number of values to generaterandomNumberOrigin - the origin (inclusive) of each random valuerandomNumberBound - the bound (exclusive) of each random valuelong values,
         each with the given origin (inclusive) and bound (exclusive)IllegalArgumentException - if streamSize is
         less than zero, or randomNumberOrigin
         is greater than or equal to randomNumberBoundpublic LongStream longs(long randomNumberOrigin, long randomNumberBound)
long values from this generator and/or one split from it; each value
 conforms to the given origin (inclusive) and bound (exclusive).longs(Long.MAX_VALUE, randomNumberOrigin, randomNumberBound).randomNumberOrigin - the origin (inclusive) of each random valuerandomNumberBound - the bound (exclusive) of each random valuelong values,
         each with the given origin (inclusive) and bound (exclusive)IllegalArgumentException - if randomNumberOrigin
         is greater than or equal to randomNumberBoundpublic DoubleStream doubles(long streamSize)
streamSize number of
 pseudorandom double values from this generator and/or one split
 from it; each value is between zero (inclusive) and one (exclusive).streamSize - the number of values to generatedouble valuesIllegalArgumentException - if streamSize is
         less than zeropublic DoubleStream doubles()
double values from this generator and/or one split from it; each value
 is between zero (inclusive) and one (exclusive).doubles(Long.MAX_VALUE).double valuespublic DoubleStream doubles(long streamSize, double randomNumberOrigin, double randomNumberBound)
streamSize number of
 pseudorandom double values from this generator and/or one split
 from it; each value conforms to the given origin (inclusive) and bound
 (exclusive).streamSize - the number of values to generaterandomNumberOrigin - the origin (inclusive) of each random valuerandomNumberBound - the bound (exclusive) of each random valuedouble values,
         each with the given origin (inclusive) and bound (exclusive)IllegalArgumentException - if streamSize is
         less than zeroIllegalArgumentException - if randomNumberOrigin
         is greater than or equal to randomNumberBoundpublic DoubleStream doubles(double randomNumberOrigin, double randomNumberBound)
double values from this generator and/or one split from it; each value
 conforms to the given origin (inclusive) and bound (exclusive).doubles(Long.MAX_VALUE, randomNumberOrigin, randomNumberBound).randomNumberOrigin - the origin (inclusive) of each random valuerandomNumberBound - the bound (exclusive) of each random valuedouble values,
         each with the given origin (inclusive) and bound (exclusive)IllegalArgumentException - if randomNumberOrigin
         is greater than or equal to randomNumberBound Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2023, Oracle and/or its affiliates.  All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.