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

    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 …

  3. Generate Random numbers without using any external functions

    Feb 23, 2013 · As long as the random numbers aren't very security critical (this would require "real" random numbers), such a recursive random number generator often satisfies the needs. The …

  4. Random numbers with Math.random() in Java - Stack Overflow

    Oct 27, 2011 · 2 If min = 5, and max = 10, and Math.random() returns (almost) 1.0, the generated number will be (almost) 15, which is clearly more than the chosen max. Relatedly, this is why every …

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

  6. How Java random generator works? - Stack Overflow

    Feb 17, 2016 · Random r = new Random(); int result = r.nextInt(6); System.out.println(result); I want to know if there is a way to "predict" next generated number and how JVM determines what number to …

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

  8. How good is java.util.Random? - Stack Overflow

    6 As RNGs go, Sun's implementation is definitely not state-of-theart, but's good enough for most purposes. If you need random numbers for cryptography purposes, there's …

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

  10. Generating Unique Random Numbers in Java - Stack Overflow

    The function declares new arrayList 'generatedUniqueIds' and populates with each unique random integer up to the required number before returning. P.S. ThreadLocalRandom class avoids common …