Java Random Boolean getBoolean(double probability)

Here you can find the source of getBoolean(double probability)

Description

get Boolean

License

Open Source License

Declaration

public static boolean getBoolean(double probability) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Random;

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

    public static boolean getBoolean(double probability) {
        return getDouble() < probability;
    }//  w w w . ja  v  a 2 s  .  c  o m

    public static double getDouble() {
        return random.nextDouble();
    }

    public static double getDouble(double max) {
        return getDouble() * max;
    }

    public static double getDouble(double min, double max) {
        return max > min ? min + getDouble(max - min) : min;
    }
}

Related

  1. generateRandomBoolean()
  2. getBoolean()
  3. getBoolean()
  4. getBoolean()
  5. getBoolean()
  6. getBooleanWithProbability(int probabilityOfTrue)
  7. randBool(float chance)
  8. randomBoolean()
  9. randomBoolean()