您可以修改底层
Collection的
Iterator(这是隐藏在
for-each环)。正确的方法是:
for (Iterator<PopulationMember> it = population.iterator(); it.hasNext();) { PopulationMemeber p = it.next(); int[] probs = ProbablityArrayDeath(GrowthRate,Death,(int)p.fitness()); if (probs[RandomNumberGen.nextRandomInt(0, 99)] == 0) { it.remove(); }}


