About 183,000 results
Open links in new tab
  1. How do I generate random integers within a specific range in Java ...

    With Java 8 they introduced the method ints(int randomNumberOrigin, int randomNumberBound) in the Random class. For example if you want to generate five random integers (or a single one) in the …

  2. 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?

  3. Generating a Random Number between 1 and 10 Java

    Random rn = new Random(); int answer = rn.nextInt(10) + 1; Is there a way to tell what to put in the parenthesis () when calling the nextInt method and what to add?

  4. Generating Unique Random Numbers in Java - Stack Overflow

    74 With Java 8+ you can use the ints method of Random to get an IntStream of random values then distinct and limit to reduce the stream to a number of unique random values.

  5. Java Generate Random Number Between Two Given Values

    Mar 11, 2011 · I would like to know how to generate a random number between two given values. I am able to generate a random number with the following: Random r = new Random (); for (int i = 0; i < …

  6. How to get a random integer in java? - Stack Overflow

    Feb 21, 2014 · public int nextInt (int n) Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.

  7. How do I generate a random integer between min and max in Java?

    What method returns a random int between a min and max? Or does no such method exist? What I'm looking for is something like this: NAMEOFMETHOD (min, max) (where min and max are ints), that …

  8. How do you use math.random to generate random ints?

    Dec 23, 2011 · int abc = (int) (Math.random() * 100); However, if you instead use the java.util.Random class it has built in method for you

  9. Java generating non-repeating random numbers - Stack Overflow

    I want to create a set of random numbers without duplicates in Java. For example I have an array to store 10,000 random integers from 0 to 9999. Here is what I have so far: import java.util.Rand...

  10. 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?