title: Java ArrayList concurrent modification
body: <p>i'm getting some problem to get this work well as i aspect:</p>
  
  <pre><code>    for(Iterator&lt;Object&gt; i = mylist.iterator(); i.hasNext();) {
          Object obj = i.next();
          ArrayList&lt;Object&gt; newlist = new ArrayList&lt;Object&gt;();
          newlist.add(obj);
          i.remove();
          for(Iterator&lt;Object&gt; in = mylist.iterator(); in.hasNext();) {
              Object next = in.next();
              if (obj != next &amp;&amp; (another condition)) {
                  newlist.add(next);
                  in.remove();
              }
          }
          if (newlist.size() &gt; 2) anotheList.add(newlist);
          else for(Object r : newlist) {
              //mylist get back object:
              mylist.add(r);
          }
      }
  </code></pre>
  
  <p>I'm trying to get an elegant way to do that without copy mylist more and more times...</p>