Collating users and their scores Is anything what could I improve on my code?

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;


public class Helper {

    public static Map&lt;User, BigDecimal&gt; createPlayersScoreMap(List&lt;User&gt; users, List&lt;Score&gt; scores) {
        List&lt;User&gt; players = getPlayers(users);
        Map&lt;User, BigDecimal&gt; playersScoreMap = new HashMap&lt;User, BigDecimal&gt;();

        for (User player: players) {
            BigDecimal sumScore = new BigDecimal(0);
            for (Score score: scores) {
                if (player.equals(score.getPlayer())) {
                    sumScore = sumScore.add(score.getResult());
                }
            }
            playersScoreMap.put(player, sumScore);
        }
        return playersScoreMap;
    }

    private static List&lt;User&gt; getPlayers(List&lt;User&gt; users) {
        List&lt;User&gt; filteredUsers = new ArrayList&lt;User&gt;(users);
        for (Iterator&lt;User&gt; it = filteredUsers.iterator(); it.hasNext();) {
            if (!it.next().isPlayer())
                it.remove(); 
        }
        return filteredUsers;
    }

}
Helper is not a good class name. You should be able to come up with something that provides more context to what the functions are doing.

In getPlayers(), I would loop and add instead of adding all and then removing.

private static List&lt;User&gt; getPlayers(List&lt;User&gt; users) {
    List&lt;User&gt; filteredUsers = new ArrayList&lt;User&gt;();
    for (User user : users) {
        if (user.isPlayer()) {
            filteredUsers.add(user);
        }
    }
    return filteredUsers;
}


I also added curly braces around the if block. It's not necessary, but it will prevent errors if you need to add an extra line later. You also included them in createPlayersScoreMap(), so it's best to be consistent.

If you have a large number of players and scores, you can make createPlayersScoreMap() more efficient (in terms of Big O processing). If n is the number of users and m is the number of scores, the method is currently O(n*m). However, if you sum all the scores first and then filter the players, you can get O(n+m).

public static Map&lt;User, BigDecimal&gt; createPlayerScores(List&lt;User&gt; users, List&lt;Score&gt; scores) {
    List&lt;User&gt; players = getPlayers(users);
    Map&lt;User, BigDecimal&gt; playerScores = new HashMap&lt;User, BigDecimal&gt;();

    for (Score score: scores) {
        User player = score.getPlayer();
        BigDecimal sumScore = score.getResult();
        if (playerScores.containsKey(player) {
            sumScore = sumScore.add(playerScores.get(player));
        }
        playerScores.put(player, sumScore);
    }
    Map&lt;User, BigDecimal&gt; filteredScores = new HashMap&lt;User, BigDecimal&gt;();
    for (User player : players) {
        filteredScores.put(player, playerScores.get(player));
    }
    return filteredScores;
}


I also change the name of the function/variable. They type system makes it obvious that you are dealing with a Map, you don't need to include it in the variable name. If the calling method has Lists and Maps that deal with players and scores, then it might be acceptable to include the type as part of the variable name.