ListIterator remove - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ListIterator remove method.

This code example shows how to use the following methods:add, next, previous, remove
    public static 
    void main(String[] args) {
        LinkedList list = new LinkedList();
        ListIterator e = list.listIterator();
        Object o = new Integer(1);
        e.add(o);
        e.previous();
        e.next();
        e.remove();
        e.add(o);
        if (!o.equals(list.get(0)))
            throw new RuntimeException("LinkedList ListIterator remove failed.");
    } 
} 
7
CodeRank
This code example shows how to use the following methods:remove
 
        /** 
         * Remove the current element. 
         */ 
        public void remove() { 
            iter.remove();
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:remove
	public T next() { 
		return underlying.next();
	} 
 
	public void remove() { 
		underlying.remove();
	} 
 
	public T update(T e) {
		underlying.set(e);
		return null; 
	} 
} 
7
CodeRank
This code example shows how to use the following methods:next, remove
    void main(String[] args) {
        List list = new LinkedList();
        Object o1 = new Integer(1);
        list.add(o1);
        ListIterator e = list.listIterator();
        e.next();
        Object o2 = new Integer (2);
        list.add(o2);
 
        try{ 
            e.remove();
        } catch (ConcurrentModificationException cme) {
            return; 
        } 
 
        throw new RuntimeException(
            "LinkedList ListIterator.remove() comodification check failed."); 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:add, hasNext, next, previous, remove
		Object c = new Object();
 
		dynamicList.add(a);
 
		try { 
			iter.set(c);
			fail("should have thrown " + IllegalStateException.class);
		} 
		catch (IllegalStateException ex) {
			// expected 
		} 
 
		iter.next();
		iter.previous();
		iter.set(b);
 
		assertEquals(1, dynamicList.size());
		assertSame(b, dynamicList.get(0));
		assertTrue(iter.hasNext());
		// move forward and back 

6
CodeRank
This code example shows how to use the following methods:remove
 
    /** 
     * {@inheritDoc} 
     */ 
    public void remove() { 
        delegate.remove();
    } 
} 
6
CodeRank
This code example shows how to use the following methods:add, next, previous, remove
    public static 
    void main(String[] args) {
        LinkedList list = new LinkedList();
        ListIterator e = list.listIterator();
        Object o = new Integer(1);
        e.add(o);
        e.previous();
        e.next();
        e.remove();
        e.add(o);
        if (!o.equals(list.get(0)))
            throw new RuntimeException("LinkedList ListIterator remove failed.");
    } 
} 
6
CodeRank
This code example shows how to use the following methods:next, remove
    void main(String[] args) {
        List list = new LinkedList();
        Object o1 = new Integer(1);
        list.add(o1);
        ListIterator e = list.listIterator();
        e.next();
        Object o2 = new Integer (2);
        list.add(o2);
 
        try{ 
            e.remove();
        } catch (ConcurrentModificationException cme) {
            return; 
        } 
 
        throw new RuntimeException(
            "LinkedList ListIterator.remove() comodification check failed."); 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:hasNext, hasPrevious, next, previous, remove
    @Test
    @SuppressWarnings("unchecked") 
    public void listIterator() { 
        ListIterator<Object> i = (ListIterator<Object>) view1.listIterator();
 
        assertTrue(i.hasNext()); 
        assertEquals(newItem("aaa", "111"), i.next()); 
        assertTrue(i.hasNext()); 
        assertEquals(newItem("bbb", "222"), i.next()); 
        assertTrue(i.hasNext()); 
        assertEquals(newItem("ccc", "333"), i.next()); 
        assertFalse(i.hasNext()); 
 
        try { 
            i.next(); 
            fail("Should throw NoSuchElementException"); 
        } catch (NoSuchElementException e) {
        } 
 
        assertTrue(i.hasPrevious()); 

7
CodeRank
This code example shows how to use the following methods:add, next, previous, remove
    public static 
    void main(String[] args) {
        LinkedList list = new LinkedList();
        ListIterator e = list.listIterator();
        Object o = new Integer(1);
        e.add(o);
        e.previous();
        e.next();
        e.remove();
        e.add(o);
        if (!o.equals(list.get(0)))
            throw new RuntimeException("LinkedList ListIterator remove failed.");
    } 
} 
7
CodeRank
remove Method Overview
Removes from the list the last element that was returned by next() or previous() (optional operation).
See Code Examples for other Java 8 ListIterator Methods: