title: Unable to use remove() method with lists in java
body: <p>I was trying to code a simple problem which goes as follows:</p>
  <blockquote>
  <p>This week there will be an important meeting of your entire department. You clearly remember your boss telling you about it. The only thing you forgot is the day of the week when the meeting will take place.</p>
  <p>You asked six of your colleagues about the meeting. None of them knew the day when it will take place, but each of them remembered one day when it will not take place. The days they remembered were distinct. For a clever programmer like you, this was enough to determine the day of the meeting.</p>
  </blockquote>
  <p>Now I have created two arrays for it, one containig all the weekdays and one containing all the days where the meeting would not take place and then created two lists from them.</p>
  <pre><code>public static void main(String[] args) {
      String[] notOnThisDay={&quot;Sunday&quot;, &quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;,   &quot;Thursday&quot;, &quot;Friday&quot;};
      String[] weekdays={&quot;Sunday&quot;, &quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;};
  
      List&lt;String&gt; list1=Arrays.asList(weekdays);
      List&lt;String&gt; list2=Arrays.asList(notOnThisDay);
      Iterator&lt;String&gt; iter=list1.iterator();
      
      while(iter.hasNext()) {
          if(list2.contains(iter.next())) {
              iter.remove();
          }
      }
  
      for(String x:list1) {
          System.out.println(x);
      }
  }
  </code></pre>
  <p>My strategy was to traverse through the weekdays list and if I find any day which is also present in the <code>notonThisDay</code> list, then I remove it. As such I am left with the day on which the meeting is to take place, but there seems to be something wrong with the <code>iter.remove()</code> method.</p>
  <p>Please point out the error. And give me advice if my algorithm is good. I accept suggestions for a better algorithm if any.</p>