code: public int nextInt(int n) throws IllegalArgumentException {
          if (n > 0) {
              if ((n & -n) == n) {
                  return (int) ((n * (long) next(31)) >> 31);
              }
              int bits;
              int val;
              do {
                  bits = next(31);
                  val = bits % n;
              } while (bits - val + (n - 1) < 0);
              return val;
          }
          throw new RuntimeException("Not strictly positive: " + n);
      }
docs: {@inheritDoc}
  <p>This default implementation is copied from Apache Harmony
  java.util.Random (r929253).</p>
  
  <p>Implementation notes: <ul>
  <li>If n is a power of 2, this method returns
  {@code (int) ((n * (long) next(31)) >> 31)}.</li>
  
  <li>If n is not a power of 2, what is returned is {@code next(31) % n}
  with {@code next(31)} values rejected (i.e. regenerated) until a
  value that is larger than the remainder of {@code Integer.MAX_VALUE / n}
  is generated. Rejection of this initial segment is necessary to ensure
  a uniform distribution.</li></ul></p>