About 50 results
Open links in new tab
  1. 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:

  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. How do I generate a random integer between min and max in Java?

    How do I generate a random integer between min and max in Java? Asked 15 years, 11 months ago Modified 6 years, 6 months ago Viewed 223k times

  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 …

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

    Feb 21, 2014 · generator.nextInt(5); which returns a random integer between 0 and 4. The reason why your original code took so long was because it was generating random integers over and …

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

    Dec 23, 2011 · Please remove the import statement importing java.util package. then your program will use random() method for java.lang by default and then your program will work. …

  7. Generating Unique Random Numbers in Java - Stack Overflow

    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.

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

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

  10. java - Get random integer in range (x, y]? - Stack Overflow

    Nov 23, 2011 · Possible Duplicate: Java: generating random number in a range How do I generate a random integer i, such that i belongs to (0,10]? I tried to use this: Random …