Java Random Boolean getBoolean()

Here you can find the source of getBoolean()

Description

Returns a pseudorandom, uniformly distributed boolean.

License

Open Source License

Declaration

public static boolean getBoolean() 

Method Source Code


//package com.java2s;
// under the terms of the GNU Lesser General Public License as published

import java.util.Random;

public class Main {
    /** The random number generator used by the methods in this class. */
    public static final Random rand = new Random();

    /**/* w  ww. ja v a  2 s  . com*/
     * Returns a pseudorandom, uniformly distributed boolean.
     */
    public static boolean getBoolean() {
        return getBoolean(rand);
    }

    /**
     * Returns a pseudorandom, uniformly distributed boolean.
     *
     * @param r the random number generator to use
     */
    public static boolean getBoolean(Random r) {
        return r.nextBoolean();
    }
}

Related

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