I had a problem with adding elements to my ArrayList while using an Iterator. In the following code it gives me this output:
a k s
But still it misses the one I had added through iterator. i.e I am missing r in my output. Is there a way I can add elements to an ArrayList using an Iterator?
import java.util.ArrayList;
import java.util.ListIterator;
public class Test 
{
public static void main(String args[])
{
    ArrayList<String> array_test= new ArrayList<String>();
    array_test.add("a");
    array_test.add("k");
    array_test.add("d");
    array_test.add("s");
    array_test.remove("d");
    ListIterator<String> it=array_test.listIterator();
    while(it.hasNext())
    {   
        String link=it.next();  
        it.add("r");
        System.out.println(link);
    }   
    //System.out.println("Contents of arrays list "+array_test);
}
}