title: Java - Generating A Set of Random Numbers Without Duplicates
body: <p>With the following code I am attempting to generate 10 random numbers between 1 and 50 without any duplicates being printed out.</p>
  
  <p>My current code is in the file RandomNum.java:</p>
  
  <pre><code>public class RandomNum
  {
      public static void main(String[] args) 
      {
               int counter = 0;
               int num = 0;
               while(counter&lt;=10)
               {
                      num=(int)(1+Math.random()*(50));
                      System.out.println("The number"+" "+num+" "+"was drawn.");
                      ++counter;
              }
      }
  }
  </code></pre>
  
  <p>This code successfully generates and prints out the value of the numbers, but I want to make it so that the program prints out 10 unique numbers between 1 and 50 rather than including any duplicates.</p>
  
  <p>How would I go about doing this?</p>
  
  <p>Thanks!</p>