title: Java List with Objects - find and replace (delete) entry if Object with certain attribute already exists
body: <p>I've been working all day and I somehow can't get this probably easy task figured out - probably a lack of coffee...<br></p>
  
  <p>I have a <code>synchronizedList</code> where some Objects are being stored. Those objects have a <code>field</code> which is something like an ID. These objects carry information about a user and his current state (simplified).<br></p>
  
  <p>The point is, that I only want one object for each user. So when the state of this user changes, I'd like to remove the "old" entry and store a new one in the <code>List</code>.<br></p>
  
  <pre><code>protected static class Objects{
      ...
      long time;
      Object ID;
      ... 
      }
  </code></pre>
  
  <p>...</p>
  
  <pre><code>if (Objects.contains(ID)) {
              Objects.remove(ID);
              Objects.add(newObject);
          } else {
              Objects.add(newObject);
          }
  </code></pre>
  
  <p>Obviously this is not the way to go but should illustrate what I'm looking for...<br>
  Maybe the data structure is not the best for this purpose but any help is welcome!</p>
  
  <p><hr>
  EDIT:<br>
  Added some information...<br>
  A <code>Set</code> does not really seem to fit my purpose. The <code>Objects</code> store some other fields besides the ID which change all the time. The purpose is, that the list will somehow represent the latest activities of a user. I only need to track the last state and only keep that object which describes this situation.<br>
  I think I will try out re-arranging my code with a <code>Map</code> and see if that works...</p>