ConcurrentModificationException when iterating on LinkedList
<p>I am not sure why this part of my code causes error but I know that if I remove an item from a list and I am just iterating through it at the same time I get this exception. I read that syncronizing would be another idea, but it is not always the right apporach.  LogCat shows the ConcurrentModificationException for <code>while (sw.hasNext())</code> row. Please note that other part of my code has abosultely no effect on the Lists. </p>

<pre><code>Iterator&lt;Weapons&gt; sw = Selected_Weapons.iterator();
                while (sw.hasNext()) {
                    Weapons www = sw.next();
                        if (www.getY()&lt;648){

                            Iterator&lt;Container&gt; cit2 = Containers.iterator();
                            while (cit2.hasNext()) {
                                Container c = cit2.next();

                                if (c.getWeaponID()==www.id){
                                    c.setWeaponID(-1);
                                    c.setIsEmpty(true);
                                    Selected_Weapons.remove(www);
                                }
                            }
                        }
                }
</code></pre>

<p>How can I solve this?</p>
