title: How do you remove duplicate integers from a given array?
body: <p>This is my code but it gives an out of bounds exception when I try to run it.</p>
  
  <p>Given an int array, return an int array with duplicate ints removed if the array contains duplicate values.</p>
  
  <pre><code>    removeDuplicateInts({3})  -&gt; {3}
      removeDuplicateInts({1, 2})  -&gt; {1, 2}
      removeDuplicateInts({7, 7})  -&gt; {7}
      removeDuplicateInts({1, 7, 1, 7, 1})  -&gt; {1, 7}
      removeDuplicateInts({1, 2, 3, 4, 5})  -&gt; {1, 2, 3, 4, 5})
      removeDuplicateInts({1, 2, 3, 2, 4, 2, 5, 2})  -&gt; {1, 2, 3, 4, 5}
  
  public static int[] removeDuplicateInts(int[] numbers) {
      ArrayList&lt;Integer&gt; num = new ArrayList&lt;Integer&gt;();
      int[] newNumbers = {};
      for (int i = 0; i &lt; numbers.length; i++) {
              num.add(numbers[i]);
              for(int j = i + 1 ; j &lt; numbers.length; j++) {
                  if (numbers[i] == numbers[j]) {
                      num.remove(numbers[i]);
                          }
                  }
              }
  for(int k = 0; k &lt; num.size(); k++){
          newNumbers[k] = num.get(k);
      }
      return newNumbers;
      }
  </code></pre>
  
  <p>I am not supposed to use java.util.Arrays so this makes it more challenging.</p>