I have this little piece of code and it gives me the concurrent modification exception. I cannot understand why I keep getting it, even though I do not see any concurrent modifications being carried out.
import java.util.*;
//package p2;
public class Class1 {
public Class1() {
}
public static void main(String[] args) {
Class1 class1 = new Class1();
List <String> s = new ArrayList <String> ();
ListIterator<String> it = s.listIterator();
for(String a:args)
s.add(a);
if(it.hasNext()) {
String item = it.next();
}
System.out.println(s);
}
}