title: How to delete elements from an array?
body: <p>How do I delete the integer at the given index and how do I compress <code>myInts</code>?</p>
  
  <p>This is what I got but I keep getting an error.</p>
  
  <pre><code>public void deleteInt(int index) {
  
      int[] newInts = Arrays.copyOf(myInts, myInts.length);
  
      if (myInts[index] != 0) {
          myInts[index] = 0;
  
          for (int i : myInts) {
              if (myInts[i] != 0) {
                  newInts[i] = myInts[i];
              }
          }
      }
      myInts = newInts;
      currentInt++;
  }
  </code></pre>
  
  <p>This is the error I get:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 11</p>
  </blockquote>