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

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

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

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

    Feb 21, 2014 · public int nextInt (int n) Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.

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

    Dec 23, 2011 · int abc = (int) (Math.random() * 100); However, if you instead use the java.util.Random class it has built in method for you

  7. 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 por si …

  8. How do I generate a random integer between min and max in Java?

    What method returns a random int between a min and max? Or does no such method exist? What I'm looking for is something like this: NAMEOFMETHOD (min, max) (where min and max are ints), that …

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

  10. java - Случайные числа - Stack Overflow на русском

    Jan 28, 2011 · import java.util.Random; // Инициализируем генератор Random rnd = new Random(System.currentTimeMillis()); // Получаем случайное число в диапазоне от min до max …