ReplayablePseudoRandom { public boolean nextBoolean() { int result = this.nextInt(2); return result != 0; } ReplayablePseudoRandom();  ReplayablePseudoRandom(double seed); double random(); int nextInt(int bound); double nextDouble(); boolean nextBoolean(); float nextFloat(); double getSeed(); void setSeed(double seed);  }
@Test public void nextBooleanTestDistribution() { int[] res = new int[2]; boolean value; for (int i = 0; i < 100; i++) { value = random.nextBoolean(); if (value) { res[0]++; } else { res[1]++; } } assertTrue(res[0] / 100d > 0.25); assertTrue(res[1] / 100d > 0.25); }