title: remove elements in list while looping
body: <p>Assuming that I have a <code>List&lt;&lt;LogFormat&gt;Log&gt;</code> like this:</p>
  
  <pre><code>[Log(name = a, accessTime = 5),
  Log(name = a, accessTime = 4),
  Log(name = a, accessTime = 3),
  Log(name = b, accessTime = 10),
  Log(name = b, accessTime = 9),
  Log(name = c, accessTime = 2),
  ...]
  </code></pre>
  
  <p>I want to left the max value of <code>accessTime</code> in every <code>name</code>, just like this:</p>
  
  <pre><code>[Log(name = a, accessTime = 5),
  Log(name = b, accessTime = 10),
  ...]
  </code></pre>
  
  <p>but I don't know how many <code>name</code>s in the List, so I tried to wrote a loop:</p>
  
  <pre><code>for (LogFormat s : Log) {
    for (LogFormat t : Log) {
      if (s.getName().equals(t.getName())
          &amp;&amp; s.getAccessTime() &gt; t.getAccessTime()) {
      Log.remove(t);
      }
    }
  }
  </code></pre>
  
  <p>But it seems that I can't use <code>.remove()</code> in a loop, how can I fix this?</p>