Java Stream: get latest version of user records
I have a list of User objects, defined as follows: 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; } } Example list: List<User> users = Arrays.asList( new User("JOHNSMITH", "John", "Smith", "Some info", 1), new User("JOHNSMITH", "John", "Smith", "Updated info"