About 14,600,000 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. java - Math.random () explanation - Stack Overflow

    Nov 1, 2011 · This is a pretty simple Java (though probably applicable to all programming) question: Math.random() returns a number between zero and one. If I want to return an integer between zero …

  4. Generating a Random Number between 1 and 10 Java

    26 This will work for generating a number 1 - 10. Make sure you import Random at the top of your code.

  5. java - Return True or False Randomly - Stack Overflow

    Jan 16, 2012 · I need to create a Java method to return true or false randomly. How can I do this?

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

  7. java - Random number with Probabilities - Stack Overflow

    Dec 2, 2013 · I am wondering what would be the best way (e.g. in Java) to generate random numbers within a particular range where each number has a certain probability to occur or not? e.g. Generate …

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

  9. 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. remember to cast it i.e

  10. How Does Java Produce a Random Number? - Stack Overflow

    Nov 29, 2015 · I know you can use Math.random() in Java to generate a random double from 0.0 to 1.0, but how does the computer pick a number? What code is the computer following to simulate …