title: Removing elements from ArrayList
body: <p>I'm trying to remove certain elements from an <code>ArrayList&lt;String&gt;</code></p>
  
  <pre><code>for(int i=0; i&lt;myList.size(); i++)
  {
      if(myList.get(i).contains("foo"))
      {
          myList.remove(i);
      }
  }
  </code></pre>
  
  <p>This however leaves "empty spaces" in my list. I would like the list to leave out the empty elements and after iterating through it shrink to neccessary size.</p>
  
  <p>Is there a smart way to do this without having to switch to a <code>LinkedList</code>?</p>