title: Java Stream: get latest version of user records
body: <p>I have a list of User objects, defined as follows:</p>
  
  <pre><code>public class User {
      private String userId; // Unique identifier
      private String name;
      private String surname;
      private String otherPersonalInfo;
      private int versionNumber;
      }
      public User(String userId, String name, String surname, String otherPersonalInfo, int version) {
        super();
        this.name = name;
        this.surname = surname;
        this.otherPersonalInfo = otherPersonalInfo;
        this.version = version;
      }
  }
  </code></pre>
  
  <p>Example list:</p>
  
  <pre><code>List&lt;User&gt; users = Arrays.asList(
    new User("JOHNSMITH", "John", "Smith", "Some info",     1),
    new User("JOHNSMITH", "John", "Smith", "Updated info",  2),
    new User("JOHNSMITH", "John", "Smith", "Latest info",   3),
    new User("BOBDOE",    "Bob",  "Doe",   "Personal info", 1),
    new User("BOBDOE",    "Bob",  "Doe",   "Latest info",   2)
  );
  </code></pre>
  
  <p>I need a way to filter this list such that I get only the latest version for each user, i.e:</p>
  
  <pre><code>{"JOHNSMITH", "John", "Smith", "Latest info", 3},
  {"BOBDOE", "Bob", "Doe", "Latest info", 2}
  </code></pre>
  
  <p>What's the best way to achieve this by using Java8 Stream API?</p>