About 54 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. java - ¿Como generar números aleatorios dentro de un rango de …

    Mar 8, 2016 · 1 Se puede utilizar el método nextInt(bound) de java.util.Random. Este método genera un número aleatorio dentro del intervalo abierto entre 0 inclusivo y el número pasado al método …

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

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

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

  6. Random variables in Java - Stack Overflow

    Sep 13, 2012 · My professor asked us to generate random variables between 0 and 0.5. I wrote this code: public class Random_Number_Generator { double randomGenerator() { Random generator = …

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

  8. ¿Como generar un numero random de una longitud específica en java?

    Hola he estado investigando sobre números aleatorios, necesito crear un numero random de 5 cifras, es decir que cada vez que genere ese numero sea aleatorio, positivo y de 5 cifras. Lo he resuelto

  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 do, then, is add …

  10. How would you give random limits in java? - Stack Overflow

    Jan 18, 2012 · So let's say you want to generate a random number, but you want it to be UNDER a specified amount. Is this possible?