title: Java: Efficient ArrayList filtering?
body: <p>I need to filter an ArrayList and remove found elements. Being relatively new to Java, I'm wondering what the most efficent method is to achieve this (matters because it runs on mobile devices). Currently I do this:</p>
  
  <pre><code>// We display only top-level dealers (parentId=-10)
  ArrayList&lt;DealerProductCount&gt; subDealers = new ArrayList&lt;DealerProductCount&gt;();
  for (DealerProductCount dealer : wsResponse.Dealers) {
      if (dealer.ParentId != -10) subDealers.add(dealer);
  }
  wsResponse.Dealers.removeAll(subDealers);
  </code></pre>
  
  <p>Can it be done without temporary objects? Maybe by directly manipulating (removing) elements of the list being iterated?</p>