Partager via


Random.NextInt Method

Definition

Overloads

NextInt()

Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence.

NextInt(Int32)

Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.

NextInt()

Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence.

[Android.Runtime.Register("nextInt", "()I", "GetNextIntHandler")]
public virtual int NextInt ();
[<Android.Runtime.Register("nextInt", "()I", "GetNextIntHandler")>]
abstract member NextInt : unit -> int
override this.NextInt : unit -> int

Returns

the next pseudorandom, uniformly distributed int value from this random number generator's sequence

Implements

Attributes

Remarks

Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence. The general contract of nextInt is that one int value is pseudorandomly generated and returned. All 2<sup>32</sup> possible int values are produced with (approximately) equal probability.

Java documentation for java.util.Random.nextInt().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

NextInt(Int32)

Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.

[Android.Runtime.Register("nextInt", "(I)I", "GetNextInt_IHandler")]
public virtual int NextInt (int bound);
[<Android.Runtime.Register("nextInt", "(I)I", "GetNextInt_IHandler")>]
abstract member NextInt : int -> int
override this.NextInt : int -> int

Parameters

bound
Int32

the upper bound (exclusive). Must be positive.

Returns

the next pseudorandom, uniformly distributed int value between zero (inclusive) and bound (exclusive) from this random number generator's sequence

Implements

Attributes

Remarks

Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence. The general contract of nextInt is that one int value in the specified range is pseudorandomly generated and returned. All bound possible int values are produced with (approximately) equal probability.

Added in 1.2.

Java documentation for java.util.Random.nextInt(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to