title: Java finding unique numbers in a single array boolean method
body: <p>I need to ask the user for 5 numbers only 50-100 is valid. I need to check as it goes and see if the numbers are unique. I have everything working except for unique method. I've been searching around the web I tried a lot of ways to get this method to work. My brain won't cooperate with me. I added a new function.</p>
  
  <pre><code>import java.util.Arrays;
  import java.util.Scanner;
  import java.util.Set;
  
  public class Valid {
  static Scanner input = new Scanner(System.in);
  public static void main(String[] args) {
  
      int[] numbers;
      int uniqueCount = 0;
      int testInput;
      numbers = new int [5];
      // go up from 0 to 4 check if isValid if not take away 1 step from i.
      for (int i = 0; i &lt; numbers.length; i++){
          System.out.print("Enter an integer (50 - 100): ");
          if (isValid(testInput = input.nextInt()) == true){
              numbers[i] = testInput;
              System.out.println(isUnique(numbers,i));
              /*if (isUnique(numbers) == true){
                  uniqueCount+=1;
                  System.out.println("Unique so far: " + uniqueCount);
  
              } else {
  
                  System.out.println("Unique so far: ");
                  System.out.print(uniqueCount);
              }*/
  
          }else {
              i--;
          }
      }
  
  
  
      }
  
  
  static boolean isValid(int n){
      boolean valid = true;
  
   // Simple if under 50 or over 100 it is not Valid
  
          if (n &lt; 50 || n &gt; 100){
              System.out.println("Error entered non valid number must be 50-100.");
              valid = false;
  
          } else valid = true;
  
          return valid  ;
  }
  
  
  static boolean isUnique(int[] nArray){
  
      for ( int i =0; i &lt; nArray.length - 1; i++){
          for (int  j =i + i ; j &lt; nArray.length; j++){
              if (nArray[i] == nArray[j]){
                  return false;
              }
          }
      }
  
  return true;
  }
  
  
  }
  
  
  
  static boolean isUnique(int[] nArray, int currentSizeOfArray){
      if (currentSizeOfArray == 0){
          //only number got to be unique
          return true;
      }else {
          for (int i = 0; nArray.length &lt; currentSizeOfArray;i++){
              if (nArray[i] == nArray[0] || nArray[i] == nArray[1] || nArray[i] == nArray[2] || nArray[i] == nArray[3] || nArray[i] == nArray[4] ){
                  // not unique
                  return false;
              }
          }
      }
  
  
  
  
      return true;
  }
  </code></pre>