I've got a program that needs to keep scores for each player in a game. I want to record these in a collection, but I'm not sure which collection would be best.
The number of players can vary and new players can join the game at any time. I want to keep a cumulative total for each player e.g.
If the scores occur in this order:
At the end of the game, I would like a list of the players and their total scores: e.g.
Tom = 4
Susan = 10
Joe = 5
I know I could build a HashMap and manage the accumulations myself, but I can't help worry that I might be missing a trick. If you know something better than HashMap for this problem then I'd be very grateful for your help.