W
W
WWH2017-10-21 11:46:06
Java
WWH, 2017-10-21 11:46:06

How to get a random boolean value?

public static boolean BooleanRand(){
        boolean a = (boolean)Math.random();
        return a;
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D3lphi, 2017-10-21
@D3lphi

private static boolean booleanRand()
{
    return new Random().nextBoolean();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question