ListIterator: add(T e) : ListIterator « java.util « Java by API






ListIterator: add(T e)

  

import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

public class Main{
  public static void main(String[] a) {
    List<String> list = new LinkedList<String>();
    list.add("A");
    list.add("B");
    list.add("C");
    list.add("D");

    ListIterator<String> iter = list.listIterator(list.size());

    while (iter.hasPrevious()) {
      System.out.println(iter.previous());
      iter.add("a");
      break;
    }
    System.out.println(list);
  }
}

   
    
  








Related examples in the same category

1.ListIterator: hasNext()
2.ListIterator: next()
3.ListIterator: nextIndex()
4.ListIterator: hasPrevious()
5.ListIterator: previous()
6.ListIterator: previousIndex()
7.ListIterator: remove()
8.ListIterator: set(T e)