About 76,000 results
Open links in new tab
  1. 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 …

  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. Random numbers with Math.random() in Java - Stack Overflow

    Oct 27, 2011 · Random numbers with Math.random () in Java Asked 13 years, 11 months ago Modified 6 years, 5 months ago Viewed 184k times

  4. java - ¿Como generar números aleatorios dentro de un rango de …

    Mar 8, 2016 · 15 En Java existen dos clases principales para generar números aleatorios: java.util.Random java.security.SecureRandom La función Math.random() usa java.util.Random …

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

  6. java - What is the best way to generate a random float value …

    The best way to generate a random floating-point value in Java (assuming you don't need a specific seed and you don't need to be cryptographically secure) is the ThreadLocalRandom …

  7. java - How do you use math.random to generate random ints

    Dec 23, 2011 · How do you use Math.random to generate random ints? My code is: int abc= (Math.random ()*100); System.out.println (abc); All it prints out is 0, how can I fix this?

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

  9. How does Math.random() EXACTLY work in Java? - Stack Overflow

    Dec 15, 2017 · I recently came across the Math.random( ) class in Java. (And) I was wondering about the class. For example, I'm trying to write a dice game that needs random numbers from …

  10. java - Math.random () v/s Random class - Stack Overflow

    The Math class in Java has a method, Math.random() which returns a pseudorandom number between 0 and 1. There is also a class java.util.Random which has various methods like …