title: Using a LinkedHashSet to store random numbers but has duplicates
body: <p>I have an app that generates a random arithmetic expression. It then generates a correct answer in a random position (<code>tag</code>) and three subsequent incorrect answers allowing the user to choose.</p>
  
  <p>I originally went with an <code>ArrayList</code> but it provides duplicates. I then converted the <code>ArrayList</code> contents in the <code>for loop</code> to a <code>Set</code> and it still produced duplicates. I then changed the initial <code>ArrayList</code> to a <code>LinkedHashSet</code> and alas, still duplicates. i'm thinking it might be the placement in my <code>for loop</code> but I've tried messing around with position and I either encounter duplicates or <code>Index</code> problems.</p>
  
  <p>I don't want to use <code>Java 8</code>'s:<code>List&lt;String&gt; deDupStringList3 = strList.stream().distinct().collect(Collectors.toList());</code> as it's <code>API/Version</code> specific. </p>
  
  <p><code>For Loop</code> Code:</p>
  
  <pre><code>    List&lt;Integer&gt; answers = new ArrayList&lt;&gt;(new HashSet&lt;Integer&gt;(5));
      answers.clear();
  
      int incorrectAnswer;
  
      for (int i = 0; i &lt; 4; i++) {
              if (i == locCorrectAnswer) {
                  answers.add(value);
              } else {
                  if (operator == '+') {
                      incorrectAnswer = value + rand.nextInt(10) + 1;
                  } else {
                      incorrectAnswer = value - rand.nextInt(10) + 1;
                  }
                  while (incorrectAnswer == value) {
                      if (operator == '+') {
                          incorrectAnswer = value + rand.nextInt(10) + 1;
                      } else {
                          incorrectAnswer = value - rand.nextInt(10) + 1;
                      }
                  }
                  answers.add(incorrectAnswer);
              }
      }
  </code></pre>
  
  <p><code>For Loop</code> code (with <code>ArrayList</code> and conversion to <code>Set</code>):</p>
  
  <pre><code>    ArrayList &lt;Integer&gt; answers;
      Set&lt;Integer&gt; s = new LinkedHashSet&lt;&gt;(answers);
  
      int incorrectAnswer;
  
      for (int i = 0; i &lt; 4; i++) {
              if (i == locCorrectAnswer) {
                  answers.add(value);
              } else {
                  if (operator == '+') {
                      incorrectAnswer = value + rand.nextInt(10) + 1;
                  } else {
                      incorrectAnswer = value - rand.nextInt(10) + 1;
                  }
                  while (incorrectAnswer == value) {
                      if (operator == '+') {
                          incorrectAnswer = value + rand.nextInt(10) + 1;
                      } else {
                          incorrectAnswer = value - rand.nextInt(10) + 1;
                      }
                  }
                  answers.add(incorrectAnswer);
              }
              s.addAll(answers);
              answers.clear();
              answers.addAll(s);
      }
  </code></pre>
  
  <p>I'm sure its a simple error but I can't see it.</p>