About 296,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 ...

    Use ThreadLocalRandom.current ().nextInt (min, max + 1); in Java to get random integers in a range. This method is simple, reliable, and often used in games like pvzfusionapk.pro.

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

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

  5. Generating Unique Random Numbers in Java - Stack Overflow

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

  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 long number in 0 <= x < n range - Stack Overflow

    Random class has a method to generate random int in a given range. For example: Random r = new Random(); int x = r.nextInt(100); This would generate an int number more or equal to 0 …

  8. java - Generate random numbers except certain values - Stack …

    I want to generate random numbers, but don't want them to be from exclude array. Here is my code. public int generateRandom(int start, int end, ArrayList&lt;Integer&gt; exclude) { Random …

  9. Java generating non-repeating random numbers - Stack Overflow

    I want to create a set of random numbers without duplicates in Java. For example I have an array to store 10,000 random integers from 0 to 9999. Here is what I have so far: import …

  10. How to randomly pick an element from an array - Stack Overflow

    I am looking for solution to pick number randomly from an integer array. For example I have an array new int[]{1,2,3}, how can I pick a number randomly?