Provides the default generator of pseudo-random values, the repeatable generator, and a base class for other RNG implementations.
An abstract class that is implemented by random number generator algorithms.
abstract class Random
Creates a java.util.Random instance that uses the specified Kotlin Random generator as a randomness source.
fun Random.asJavaRandom(): Random
Gets the next random Int
from the random number generator in the specified range.
fun Random.nextInt(range: IntRange): Int
Gets the next random Long
from the random number generator in the specified range.
fun Random.nextLong(range: LongRange): Long
Fills the specified unsigned byte array with random bytes and returns it.
fun Random.nextUBytes(array: UByteArray): UByteArray
Creates an unsigned byte array of the specified size, filled with random bytes.
fun Random.nextUBytes(size: Int): UByteArray
Gets the next random UInt from the random number generator.
fun Random.nextUInt(): UInt
Gets the next random UInt from the random number generator less than the specified until bound.
fun Random.nextUInt(until: UInt): UInt
Gets the next random UInt from the random number generator in the specified range.
fun Random.nextUInt(from: UInt, until: UInt): UInt
Gets the next random ULong from the random number generator.
fun Random.nextULong(): ULong
Gets the next random ULong from the random number generator less than the specified until bound.
fun Random.nextULong(until: ULong): ULong
Gets the next random ULong from the random number generator in the specified range.
fun Random.nextULong(from: ULong, until: ULong): ULong
Returns a repeatable random number generator seeded with the given seed Int
value.
fun Random(seed: Int): Random
Returns a repeatable random number generator seeded with the given seed Long
value.
fun Random(seed: Long): Random
© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.random/index.html