title: Java Array of unique randomly generated integers
body: <pre><code>public static int[] uniqueRandomElements (int size) {
  
      int[] a = new int[size];
  
      for (int i = 0; i &lt; size; i++) {
          a[i] = (int)(Math.random()*10);
  
          for (int j = 0; j &lt; i; j++) {
              if (a[i] == a[j]) {
                  a[j] = (int)(Math.random()*10);
              }
          }   
      }
  
      for (int i = 0; i &lt; a.length; i++) {
          System.out.print(a[i]+" ");
      }
      System.out.println();
      return a;
  }
  </code></pre>
  
  <p>I have a method above which should generate an array of random elements that the user specifies. The randomly generated integers should be between 0 and 10 inclusive. I am able to generate random integers but the problem I have is checking for uniqueness. My attempt to check for uniqueness is in my code above but the array still contains duplicates of integers. What am I doing wrong and could someone give me a hint?</p>