title: Generate 5 sets of 6 random numbers within range 1-49, by making sure there aren’t any duplicates in each set?
body: <p>I am making a program that will generate 5 sets of 6 random numbers to be used in the lottery however at the moment when the sets of numbers are printed they contain duplicates. How can I make it so every number in each set is unique? (Note each set should be ordered in ascending order from lowest to highest)</p>
  
  <pre><code>import java.util.Arrays;
  
  public class tasksTest {
  
      public static void main(String[] args) {
  
  
      System.out.println("Your lottery numbers are:");
  
      for(int i=1; i&lt;6; i++){
  
          int[]lotteryNumbers = new int[6];
  
          for(int ii = 0; ii &lt; lotteryNumbers.length; ii++){
              lotteryNumbers[ii] = (int)(Math.random()*49 + 1);
          }
  
          Arrays.sort(lotteryNumbers);
          System.out.println(Arrays.toString(lotteryNumbers));
      }
   }
  }
  </code></pre>