Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5057306

(rand) expand the random number generation APIs

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0
    • core-libs
    • sparc
    • solaris_9

      This is a slightly annoying thing to have to write, it would be nice to have a Random.nextInt(min,max) inclusive.

      private static final int MAX_KEY_SIZE = 120;
      private static final int MIN_KEY_SIZE = 1;
      ...
      // Assumes MAX_KEY_SIZE >> MIN_KEY_SIZE
      int keyLen = generator.nextInt(MAX_KEY_SIZE - MIN_KEY_SIZE + 1) +
                   MIN_KEY_SIZE;

      Other possibilities include a Math.random(int) that can be used
      without worrying about creating your own Random if you don't care about it,
      and perhaps a Random.nextLong(long).


      ###@###.### 2004-06-03

            Unassigned Unassigned
            mmcclosksunw Michael Mccloskey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: