Java Two List<?> Using Iterator remove element from one?
<p>i have Two list<code>,List&lt;String&gt; and List&lt;Item&gt;.</code></p>

<pre><code>public class Item {
    private String name;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}
</code></pre>

<p><strong>My Code::</strong></p>

<pre><code>public class Twolist {

    List&lt;Item&gt; list1 = new ArrayList&lt;&gt;();
    List&lt;String&gt; list2 = new ArrayList&lt;&gt;();


    public Twolist() {

        Item item = new Item();
        item.setName("itemname1");
        list1.add(item);

        item = new Item();
        item.setName("itemname2");
        list1.add(item);

        item = new Item();
        item.setName("itemname3");
        list1.add(item);

        item = new Item();
        item.setName("itemname4");
        list1.add(item);

        item = new Item();
        item.setName("itemname5");
        list1.add(item);

        item = new Item();
        item.setName("itemname6");
        list1.add(item);

        item = new Item();
        item.setName("itemname7");
        list1.add(item);

        item = new Item();
        item.setName("itemname8");
        list1.add(item);

        // list 2 start here

        list2.add("itemname2");
        list2.add("itemname4");
        list2.add("itemname6");
        list2.add("itemname8");

        Iterator&lt;Item&gt; it1 = list1.iterator();

        while (it1.hasNext()) {
            Item item2 = (Item) it1.next();
            System.out.println(item2.getName());


            for (int i = 0; i &lt; list2.size(); i++) {
                String str = list2.get(i);

                if (item2.equals(str)) {

                } else {
                    it1.remove();
                }
            }

        }

        System.out.println(list1.size());
    }

    public static void main(String[] args) {

        new Twolist();
    }
</code></pre>

<p><strong>Error::</strong></p>

<pre><code>itemname1
Exception in thread "main" java.lang.IllegalStateException
    at java.util.ArrayList$Itr.remove(ArrayList.java:804)
    at com.samir.CollectionP.Twolist.&lt;init&gt;(Twolist.java:67)
    at com.samir.CollectionP.Twolist.main(Twolist.java:78)
</code></pre>

<p>if name in <code>List&lt;Item&gt;</code> is equals <code>List&lt;String&gt;</code>is same then remove element from <code>List&lt;Item&gt;</code>. how can i remove element from <code>List&lt;Item&gt;</code>?</p>
