Udostępnij za pośrednictwem


Random.NextBoolean Method

Definition

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

[Android.Runtime.Register("nextBoolean", "()Z", "GetNextBooleanHandler")]
public virtual bool NextBoolean ();
[<Android.Runtime.Register("nextBoolean", "()Z", "GetNextBooleanHandler")>]
abstract member NextBoolean : unit -> bool
override this.NextBoolean : unit -> bool

Returns

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

Attributes

Remarks

Returns the next pseudorandom, uniformly distributed boolean value from this random number generator's sequence. The general contract of nextBoolean is that one boolean value is pseudorandomly generated and returned. The values true and false are produced with (approximately) equal probability.

The method nextBoolean is implemented by class Random as if by:

{@code
            public boolean nextBoolean() {
              return next(1) != 0;
            }}

Added in 1.2.

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

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