Javatpoint Logo
Javatpoint Logo

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

Test it Now

Output:

Random booleanvalue : false
Random booleanvalue : true

Example 2

Test it Now

Output:

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




Help Others, Please Share

facebook twitter pinterest