/** * Returns a pseudo-random uniformly distributed {@code boolean}. */ public boolean nextBoolean() { return next(1) != 0; }
java.lang.Thread.State: RUNNABLE at java.util.Random.next(Random.java:189) at java.util.Random.nextInt(Random.java:239) at sun.misc.Hashing.randomHashSeed(Hashing.java:254) at java.util.HashMap.<init>(HashMap.java:255) at java.util.HashMap.<init>(HashMap.java:297)
/** * Returns a pseudo-random uniformly distributed {@code int}. */ public int nextInt() { return next(32); }
public class MyRandom extends Random { public MyRandom() {} public MyRandom(int seed) { super(seed); } public int nextNonNegative() { return next(Integer.SIZE - 1); } }
/** * Returns a pseudo-random uniformly distributed {@code float} * in the half-open range [0.0, 1.0). */ public float nextFloat() { return (next(24) / 16777216f); }
/** * Returns a pseudo-random uniformly distributed {@code int} * in the half-open range [0, n). */ public int nextInt(int n) { if (n <= 0) { throw new IllegalArgumentException("n <= 0: " + n); } if ((n & -n) == n) { return (int) ((n * (long) next(31)) >> 31); } int bits, val; do { bits = next(31); val = bits % n; } while (bits - val + (n - 1) < 0); return val; }
@Override protected synchronized int next(int bits) { return super.next(bits); } }
/** * Returns a pseudo-random uniformly distributed {@code boolean}. */ public boolean nextBoolean() { return next(1) != 0; }
/** * Returns a pseudo-random uniformly distributed {@code int}. */ public int nextInt() { return next(32); }
/** * Returns a pseudo-random uniformly distributed {@code float} * in the half-open range [0.0, 1.0). */ public float nextFloat() { return (next(24) / 16777216f); }
/** * Simply use the method of the super class * * @param bits - random bits * @return the next pseudorandom value from this random number * generator's sequence. */ protected int next(int bits) {return super.next(bits);}
/** * Returns a pseudo-random uniformly distributed {@code boolean}. */ public boolean nextBoolean() { return next(1) != 0; }
/** * Returns a pseudo-random uniformly distributed {@code float} * in the half-open range [0.0, 1.0). */ public float nextFloat() { return (next(24) / 16777216f); }