in my program I've created teams(football for example) and now I want to create a method where every team plays a match against all the other teams. My method throws a ConcurrentModificationException. Here it is:
public void playMatches(){
for (Team team : mTeams) {
mTeams.remove(team);
for (Team team1 : mTeams) {
match(team, team1);
}
mTeams.add(team);
}
}
I'm removing the team itself from mTeams, so that it doesn't play against itself, but this throws the Exception. How can I handle that?