Match users to their preferences by ID I am using Java, but coming from a JavaScript background. I have two objects:

a list of users
an Iterable of users preferences

I am joining them into a new users object that I call newUser, and then adding newUser to a List of User and returning that.
I need to match up users to their user preferences based on a shared id.  If I was using JS I would get the id of the user and filter the user preferences based on the same id.  I wasn't able to figure that out, so I used a for loop for users and then a foreach loop for users preferences and the used an if statement to find a match.
var users = service.getUsers();
List&lt;User&gt; value = new ArrayList&lt;User&gt;();
var usersPreferences = _userRepo.findAll();
for(int i =0; i &lt; users.size(); i++){
    var user = users.get(i);
    boolean[] isFound = {false};
    usersPreferences.forEach(prefUser -&gt; {
        if(prefUser.getId() == user.getId()){
            User newUser = new User(user, prefUser);
            value.add(newUser);
            isFound[0] = true;
        }
    });
    if(!isFound[0]){
        User newUser = new User(user);
            value.add(newUser);
    }
}
return value;
var users = service.getUsers();
        List&lt;User&gt; value = new ArrayList&lt;User&gt;();
        var usersPreferences = _userRepo.findAll();

Personally, I dislike var with a passion because of exactly such usage. I can't see half-the types, so I have to make a few assumptions here.

for(int i =0; i &lt; users.size(); i++){

First, I'm against using single-letter variable names, with the only exception being dimensions. Having said that, you can most likely use a for-each loop here (I'm not seeing the type of users, but I assume that it is a List).
for (User user : users) {


List&lt;User&gt; value = new ArrayList&lt;User&gt;();

This variable name could be better, because it doesn't make much sense.

            boolean[] isFound = {false};
            usersPreferences.forEach(prefUser -&gt; {
                if(prefUser.getId() == user.getId()){
                    User newUser = new User(user, prefUser);
                    value.add(newUser);
                    isFound[0] = true;
                }
            });
            if(!isFound[0]){
                User newUser = new User(user);
                    value.add(newUser);
            }

Instead of using a lambda, you could use a simple for-each loop:
            boolean isFound = false;
            for (UserPreference userPreference : userPreferences) {
                if(prefUser.getId() == user.getId()){
                    User newUser = new User(user, prefUser);
                    value.add(newUser);
                    isFound = true;
                }
            }
            if(!isFound){
                User newUser = new User(user);
                value.add(newUser);
            }


Even better would be if you would extract the second loop into its own function, as that would reduce the complexity of your logic:
private User createUserWithPreferences(User user, List&lt;UserPreferences&gt; userPreferences) {
    for (UserPreference userPreference : userPreferences) {
        if (userPreference.getUserId() == user.getId()) {
            return new User(user, userPreference);
        }
    }
    
    return new User(user);
}

List&lt;User&gt; createdUsers = new ArrayList&lt;&gt;();

for (User user : users) {
    createdUsers.add(createUserWithPreferences(user, userPreferences);
}