Java Random Boolean getBoolean()

Here you can find the source of getBoolean()

Description

Gets a random boolean.

License

Open Source License

Return

random boolean.

Declaration

public static boolean getBoolean() 

Method Source Code


//package com.java2s;
import java.util.Random;

public class Main {
    private static final Random RANDOM = new Random();

    /**/*from w  w  w  . ja v a  2  s  .  c  o  m*/
     * Gets a random boolean.
     *
     * @return random boolean.
     */
    public static boolean getBoolean() {
        return RANDOM.nextInt(1) == 1;
    }
}

Related

  1. generateRandomBoolean()
  2. getBoolean()
  3. getBoolean()
  4. getBoolean()
  5. getBoolean(double probability)
  6. getBooleanWithProbability(int probabilityOfTrue)
  7. randBool(float chance)