Random.nextBoolean() has the following syntax.
public boolean nextBoolean()
In the following code shows how to use Random.nextBoolean() method.
/*w w w . j a va 2 s . c o m*/ import java.util.Random; public class Main { public static void main( String args[] ){ Random randomno = new Random(); // get next next boolean value boolean value = randomno.nextBoolean(); // check the value System.out.println("Value is: " + value); } }
The code above generates the following result.