How can I generate a random boolean? Is there a method for this?
Thanks in advance
I think you could do it like this, but I didn't test this.
public boolean randomBoolean() { int r = (int) Math.random() * 10; if (r < 5) return true; else return false; }
- Nick Nisi
wow... try this....
Random random = new Random(); boolean a = random.nextBoolean();
wow... try this.... Random random = new Random(); boolean a = random.nextBoolean();
Worked great. I was looking in Math and not Random.
Thanks