Get Random boolean in Java
Description
The following code shows how to get Random boolean.
Example
//from www . jav a 2 s. c o m
import java.util.Random;
public class Main {
public static void main(String[] argv) throws Exception {
Random rand = new Random();
boolean b = rand.nextBoolean();
System.out.println(b);
}
}
The code above generates the following result.