How to return the value of a HashMap
This question already has an answer here:
int total =teamPlayers.get(TeamType.TEAM_ONE).size() + teamPlayers.get(TeamType.TEAM_TWO).size()
should work. Instead of referencing your old post can you post your current code? hard to know what changes youve made and what suggestions you took from the last post.
updated answer for iterating through every entry in your TeamType enum:
int total = 0;
for(TeamType type : TeamType.values()){
total += teamPlayers.get(type).size();
}
so the for each loop will iterate through each entry in your enum, and total will accumulate the number of players for each team
链接地址: http://www.djcxy.com/p/17992.html上一篇: 通过HashMap循环
下一篇: 如何返回一个HashMap的值