title: Java List removing items without any action
body: <p>I'm facing a weird behavior in my Java code using List.</p>
  <p>The code is very simple, I have a List of Object called <code>AccessRequest</code> which comes from a database and I'm using this first List to create a new one but with a filter to select only a few objects.</p>
  <p>Here is the code :</p>
  <pre><code>private void updateCommentIfNeeded() {
      List&lt;AccessRequest&gt; accessRequestList = getAllRequest();
      List&lt;AccessRequest&gt; commentsList = getCommentsListProcessedManually(accessRequestList);
  }
  
  public List&lt;AccessRequest&gt; getCommentsListProcessedManually(List&lt;AccessRequest&gt; accessRequests) {
  
      accessRequests.removeIf(ar -&gt; !ar.getComment().equals(&quot;To be processed manually&quot;));
  
      if (accessRequests.size() != 0) {
          SQLServerConnection sqlServerConnection = new SQLServerConnection(sqlServerUrl);
          accessRequests.removeIf(ar -&gt; !sqlServerConnection.emailExists(ar.getEmail()));
      }
      return accessRequests;
  }
  </code></pre>
  <p>I'm supposed to get a second List only containing the objects that has their comments to <code>To be processed manually</code>, which I do. But the weird part is that the first List also takes the value of the second as if I wrote <code>accessRequestList = commentsList</code> but there is no such thing and I'm using local variable.</p>
  <p>Ex :</p>
  <ul>
  <li>I have 3 objects in my first List, but only one containing the required comment</li>
  <li>Both list ends with containing the only objects containing the comment</li>
  </ul>
  <p>I'm kind of lost here if anyone has an idea !</p>