title: Error checking duplicate user-input array values
body: <p>I am self-learning Java and am stuck on a simple project. I'd like to receive 6 <strong>unique</strong> 'lottery' numbers from a user.</p>
  
  <ol>
  <li>User will be asked to input an integer.</li>
  <li>Each user input will be placed into an array.</li>
  <li>If the user inputs a previously input number, I want to prompt to reenter the number again.</li>
  <li>Recheck the new input. If unique, continue the for loop. If non-unique, run step 3 again.</li>
  </ol>
  
  <p>So far, all I have is:</p>
  
  <pre><code>public static int[] userLottoInput()
  {
      int[] userNums = new int[6];        
      Scanner keyboard = new Scanner(System.in);
  
      for (int i = 0; i &lt; userNums.length; i++ ) {
          System.out.printf("Enter Lottery number %d: ", i + 1);
          userNums[i] = keyboard.nextInt();
  
          for (int k=i; k&lt;userNums.length; k++)  {
              while (k!=i &amp;&amp; userNums[k] == userNums[i])  {
                  System.out.printf("if");
                  System.out.printf("Error! Try again: ");
                  userNums[i] = keyboard.nextInt();
              }
          }
      }
  }   
  </code></pre>
  
  <p>Any help is appreciated!!</p>