About 50 results
Open links in new tab
  1. Getting random numbers in Java - Stack Overflow

    I would like to get a random value between 1 to 50 in Java. How may I do that with the help of Math.random();? How do I bound the values that Math.random() returns?

  2. How do I generate random integers within a specific range in Java ...

    Java 7+ In Java 1.7 or later, the standard way to do this (generate a basic non-cryptographically secure random integer in the range [min, max]) is as follows:

  3. Java random number with given length - Stack Overflow

    Mar 22, 2011 · I need to genarate a random number with exactly 6 digits in Java. I know i could loop 6 times over a randomizer but is there a nother way to do this in the standard Java SE?

  4. Generating a Random Number between 1 and 10 Java

    I want to generate a number between 1 and 10 in Java. Here is what I tried:

  5. Generating Unique Random Numbers in Java - Stack Overflow

    Add each number in the range sequentially in a list structure. Shuffle it. Take the first 'n'. Here is a simple implementation. This will print 3 unique random numbers from the range 1-10.

  6. How to generate 4 digit random numbers in java from 0000 to 9999

    Jan 11, 2018 · int number = ThreadLocalRandom.current().nextInt(1000, 9999 + 1); But it won't generate 4 digit numbers like 0004,0035 and so on... I searched for similar questions but none solved, they …

  7. Java: random long number in 0 <= x < n range - Stack Overflow

    Random class has a method to generate random int in a given range. For example: Random r = new Random(); int x = r.nextInt(100); This would generate an int number more or equal to 0 and less than...

  8. Java Generate Random Number Between Two Given Values

    Mar 11, 2011 · Java doesn't have a Random generator between two values in the same way that Python does. It actually only takes one value in to generate the Random. What you need to do, then, is add …

  9. java - What is the best way to generate a random float value included ...

    The best way to generate a random floating-point value in Java (assuming you don't need a specific seed and you don't need to be cryptographically secure) is the ThreadLocalRandom class.

  10. Best way to generate unique Random number in Java

    Sep 13, 2022 · I have to generate unique serial numbers for users consisting of 12 to 13 digits. I want to use random number generator in Java giving the system. Time in milliseconds as a seed to it. Please …