title: Java generating non-repeating random numbers
body: <p>I want to create a set of random numbers without duplicates in Java.</p>
  
  <p>For example I have an array to store 10,000 random integers from 0 to 9999.</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>import java.util.Random;
  public class Sort{
  
      public static void main(String[] args){
  
          int[] nums = new int[10000];
  
          Random randomGenerator = new Random();
  
          for (int i = 0; i &lt; nums.length; ++i){
              nums[i] = randomGenerator.nextInt(10000);
          }
      }
  }
  </code></pre>
  
  <p>But the above code creates duplicates.  How can I make sure the random numbers do not repeat?</p>