Code example for ListIterator

Methods: hasNextnextremove

0
    l.add(1);
    l.add(2);
    l.add(3);
     
    ListIterator<Integer> it = l.listIterator();
    expect(it.next().equals(Integer.valueOf(1)));
    it.remove();
    expect(it.next().equals(Integer.valueOf(2)));
    it.remove();
    expect(it.next().equals(Integer.valueOf(3)));
    it.remove();
    expect(! it.hasNext());
    expect(l.isEmpty());
 
    l.add(1);
    l.add(2);
    l.add(3);
     
    it = l.listIterator(1);
    expect(it.next().equals(Integer.valueOf(2)));
Stop searching for code, let great code find you!  Add Codota to your java IDE