Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/classes/java/util/Random.java
          +++ new/src/share/classes/java/util/Random.java
↓ open down ↓ 69 lines elided ↑ open up ↑
  70   70      /** use serialVersionUID from JDK 1.1 for interoperability */
  71   71      static final long serialVersionUID = 3905348978240129619L;
  72   72  
  73   73      /**
  74   74       * The internal state associated with this pseudorandom number generator.
  75   75       * (The specs for the methods in this class describe the ongoing
  76   76       * computation of this value.)
  77   77       */
  78   78      private final AtomicLong seed;
  79   79  
  80      -    private final static long multiplier = 0x5DEECE66DL;
  81      -    private final static long addend = 0xBL;
  82      -    private final static long mask = (1L << 48) - 1;
       80 +    private static final long multiplier = 0x5DEECE66DL;
       81 +    private static final long addend = 0xBL;
       82 +    private static final long mask = (1L << 48) - 1;
  83   83  
  84   84      /**
  85   85       * Creates a new random number generator. This constructor sets
  86   86       * the seed of the random number generator to a value very likely
  87   87       * to be distinct from any other invocation of this constructor.
  88   88       */
  89   89      public Random() {
  90   90          this(seedUniquifier() ^ System.nanoTime());
  91   91      }
  92   92  
↓ open down ↓ 185 lines elided ↑ open up ↑
 278  278       * implemented by this class are known to have short periods in the
 279  279       * sequence of values of their low-order bits.  Thus, this special case
 280  280       * greatly increases the length of the sequence of values returned by
 281  281       * successive calls to this method if n is a small power of two.
 282  282       *
 283  283       * @param n the bound on the random number to be returned.  Must be
 284  284       *        positive.
 285  285       * @return the next pseudorandom, uniformly distributed {@code int}
 286  286       *         value between {@code 0} (inclusive) and {@code n} (exclusive)
 287  287       *         from this random number generator's sequence
 288      -     * @exception IllegalArgumentException if n is not positive
      288 +     * @throws IllegalArgumentException if n is not positive
 289  289       * @since 1.2
 290  290       */
 291  291  
 292  292      public int nextInt(int n) {
 293  293          if (n <= 0)
 294  294              throw new IllegalArgumentException("n must be positive");
 295  295  
 296  296          if ((n & -n) == n)  // i.e., n is a power of 2
 297  297              return (int)((n * (long)next(31)) >> 31);
 298  298  
↓ open down ↓ 277 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX