About 51 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 17+ As of Java 17, the psuedorandom number generating classes in the standard library implement the RandomGenerator interface. See the linked JavaDoc for more information. For …

  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: Random rn = new Random(); int answer = rn.nextInt(10) + 1; Is there a way to tell what to put in the parenthesis () when

  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. 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 …

  7. 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 …

  8. True random generation in Java - Stack Overflow

    The NSA and Intel’s Hardware Random Number Generator To make things easier for developers and help generate secure random numbers, Intel chips include a hardware-based random number …

  9. java - Generate random numbers except certain values - Stack Overflow

    I want to generate random numbers, but don't want them to be from exclude array. Here is my code. public int generateRandom(int start, int end, ArrayList<Integer> exclude) { Random rand ...

  10. Java random numbers using a seed - Stack Overflow

    Sep 17, 2012 · That's an important feature allowing tests. Check this to understand pseudo random generation and seeds: Pseudorandom number generator A pseudorandom number generator …