On 2013-06-14, at 8:41 AM, Remi Forax <fo...@univ-mlv.fr> wrote: > In the codes I was referring to, there was always a way to know that the > remove was done at the end by example by knowing that the last element was a > special sentinel or by using a counter. > So is the following program bugged ? > > List<Integer> l = new ArrayList<>(Arrays.asList(1, 2, null)); > for (Integer i : l) { > if (i == null) { > l.set(l.size() - 1, 3); // change the last value to 3 > } > }
There will come a time when it should be considered buggy, yes. Assume the future is parallel. Java's intricately specified serial legacy may cause problems, and if it gets to the point that "every good programmer knows" that the rule is to sprinkle parallel-parallel-parallel-parallel throughout their code, they may eventually wander off to find another language. David