title: Unique or non repeating random number generation
body: <p>I am trying to generate unique random number using the below function. Whenerver I run my code in a loop of 1000, it generates duplicate number also.</p>
  
  <p>Code</p>
  
  <pre><code>private static String randomize() {
          int count = 10;
          List&lt;Integer&gt; digits = createList(count);
          Collections.shuffle(digits); // this re-arranges the elements in the list
          return listToString(digits);
      }
  
      private static &lt;T&gt; String listToString(List&lt;T&gt; list) {
          StringBuilder result = new StringBuilder();
          for (T object : list) {
              result.append(object);
          }
          return result.toString();
      }
  
      private static List&lt;Integer&gt; createList(int size) {
          List&lt;Integer&gt; result = new ArrayList&lt;Integer&gt;(size);
          for (int i = 0; i &lt; size; i++) {
              result.add(i);
          }
          return result;
      }
  
  public static void main(String[] args) {
          for (int i = 0; i &lt; 1000; i++) {
              String strName = randomize();
              System.out.println(strName);
          }
  </code></pre>
  
  <p>I searched a lot in google and tried ThreadLocal also, it did not help me. Any help or guide on this will be really helpful. My idea is to generate 10 digit non-repeating random number within a loop.</p>