Below is some code (removed much of it for clarity) which shows my issue of concurrent list modification:
for (final Week week : this.demand.getWeeks().getAllWeeks()) {
final List<Week> weeksExcludingThisWeek = this.demand.getWeeks().getAllWeeks();
weeksExcludingThisWeek.remove(week);
}
As far as I was aware I was removing the reference to the same week object, but in a different list than is used in the for loop.
How do I prevent this from occurring?