Java Random nextBoolean() Method

The nexBooleant() method of Random class returns the next pseudorandom, uniformly distributed boolean value from the random number generator's sequence.

Syntax

Parameters

NA

Return Value

The nextBoolean () method returns the next pseudorandom boolean value.

Example 1

Output:

Random booleanvalue : false
Random booleanvalue : true

Example 2

Output:

For Head: enter true.
For tail : enter false
Enter your choice : false
Outcome is : false
Congratulations!!You won the round!