Java Utililty Methods Random Boolean

List of utility methods to do Random Boolean

Description

The list of methods to do Random Boolean are organized into topic(s).

Method

booleangenerateRandomBoolean()
generate Random Boolean
return Math.random() >= 0.5;
booleangetBoolean()
Gets a random boolean.
return RANDOM.nextInt(1) == 1;
booleangetBoolean()
get Boolean
return getIntegerMoreThanZeroLessThan(3) == 1;
booleangetBoolean()
get Boolean
if (random == null)
    init();
return random.nextBoolean();
booleangetBoolean()
Returns a pseudorandom, uniformly distributed boolean.
return getBoolean(rand);
booleangetBoolean(double probability)
get Boolean
return getDouble() < probability;
booleangetBooleanWithProbability(int probabilityOfTrue)
Gets a random boolean with a probability of being true.
if (probabilityOfTrue <= 0) {
    return false;
else {
    return new Random().nextInt(100) + 1 <= probabilityOfTrue;
booleanrandBool(float chance)
rand Bool
float v = rand.nextFloat();
return chance > v;
booleanrandomBoolean()
random Boolean
return Math.abs(Math.random() * 1000) % 57 != 0;
booleanrandomBoolean()
random Boolean
return Math.random() < 0.5d;