Bug in ArrayList iterator

Remi Forax forax at univ-mlv.fr
Wed Jan 7 09:45:46 UTC 2015


A simple Java question, what this code does ?

   ArrayList<String> list = new ArrayList<>();
   list.add("foo");
   list.add("bar");
   for(String s: list) {
     list.remove(s);
   }

:(

Rémi
tip: the bug lies in ArrayList.Itr.hasNext() (and 
AbstractList.Itr.hasNext()).




More information about the core-libs-dev mailing list