import java.util.ArrayList;
import java.util.Iterator;
import java.util.ListIterator;
class IteratorDemo {
public static void main(String args[]) {
ArrayList al = new ArrayList();
al.add("C");
al.add("A");
al.add("E");
al.add("B");
al.add("D");
al.add("F");
Iterator itr = al.iterator();
while (itr.hasNext()) {
String element = itr.next();
System.out.print(element + " ");
}
ListIterator litr = al.listIterator();
while (litr.hasNext()) {
String element = litr.next();
litr.set(element + "+");
}
itr = al.iterator();
while (itr.hasNext()) {
String element = itr.next();
System.out.print(element + " ");
}
while (litr.hasPrevious()) {
String element = litr.previous();
System.out.print(element + " ");
}
}
}