nextInt

open override fun nextInt(): Int(source)

Gets the next random Int from the random number generator.

Generates an Int random value uniformly distributed between Int.MIN_VALUE and Int.MAX_VALUE (inclusive).

Since Kotlin

1.3

Samples


open override fun nextInt(until: Int): Int(source)

Gets the next random non-negative Int from the random number generator less than the specified until bound.

Generates an Int random value uniformly distributed between 0 (inclusive) and the specified until bound (exclusive).

Since Kotlin

1.3

Parameters

until

must be positive.

Throws

if until is negative or zero.

Samples


open override fun nextInt(from: Int, until: Int): Int(source)

Gets the next random Int from the random number generator in the specified range.

Generates an Int random value uniformly distributed between the specified from (inclusive) and until (exclusive) bounds.

Since Kotlin

1.3

Throws

if from is greater than or equal to until.

Samples