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

(rand) expand the random number generation APIs

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_9

      Description

      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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: