ListIterator next - 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 next 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:next
	public boolean hasNext() { 
		return underlying.hasNext();
	} 
 
	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:hasNext, hasPrevious, next, nextIndex, previous
		Wrapper date = new DateWrapper(time1);
 
		addService(date);
		addService(date);
 
		assertEquals(0, iter.nextIndex());
		Wrapper proxy1 = (Wrapper) iter.next();
 
		assertEquals(new Long(time1), proxy1.execute());
		removeService(date);
 
		assertEquals(1, iter.nextIndex());
		assertFalse(iter.hasNext());
		assertTrue(iter.hasPrevious());
		Wrapper proxy2 = ((Wrapper) iter.previous());
		assertEquals(new Long(time1), proxy2.execute());
 
		assertSame(proxy1, proxy2);
 
	} 
7
CodeRank
This code example shows how to use the following methods:next
    // use of the iterator. 
    Assert.assertTrue("checkDirs did not remove test file from directory list",
        dc.checkDirs());
 
    // Verify no ConcurrentModification is thrown 
    li.next();
  } 
 
  @Test 
  public void testCreateDirectories() throws IOException { 
    Configuration conf = new Configuration();
    conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077");
    FileContext localFs = FileContext.getLocalFSFileContext(conf);
 
    String dirA = new File(testDir, "dirA").getPath();
    String dirB = new File(dirA, "dirB").getPath();
    String dirC = new File(testDir, "dirC").getPath();
    Path pathC = new Path(dirC);
    FsPermission permDirC = new FsPermission((short)0710);
 
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:hasNext, next
		while(items.hasNext()) items.next();
	} 
	 
	@Override 
	public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder<T> nextImpl() { 
		if(!items.hasNext())
			return null; 
		return new Holder<T>(items.next());
	} 
	 
	@Override 
	public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder<T> previousImpl() { 
		if(!items.hasPrevious())
			return null; 
		return new Holder<T>(items.previous());
	} 
 
} 
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:next
        return this.iterator.hasNext();
    } 
 
    public T next() 
    { 
        return this.iterator.next();
    } 
 
    public boolean hasPrevious() 
    { 
        return this.iterator.hasPrevious();
    } 
 
    public T previous() 
    { 
        return this.iterator.previous();
    } 
 
    public int nextIndex() 
    { 
6
CodeRank
This code example shows how to use the following methods:hasNext, hasPrevious, next, nextIndex, previous
 
	@Test 
	public void listIteratorTest() { 
		List<Character> list = new CharacterList("abc");
		ListIterator<Character> itr = list.listIterator();
		Assert.assertTrue(itr.hasNext());
		Assert.assertFalse(itr.hasPrevious());
		Assert.assertEquals(0, itr.nextIndex());
		Assert.assertEquals(-1, itr.previousIndex());
		Character c = itr.next();
		Assert.assertNotNull(c);
		Assert.assertEquals('a', (char) c);
		Assert.assertTrue(itr.hasNext());
		Assert.assertTrue(itr.hasPrevious());
		Assert.assertEquals(1, itr.nextIndex());
		Assert.assertEquals(0, itr.previousIndex());
		c = itr.next();
		Assert.assertNotNull(c);
		Assert.assertEquals('b', (char) c);
		Assert.assertTrue(itr.hasNext());

6
CodeRank
This code example shows how to use the following methods:hasNext, next, previous, set
  } 
   
  public void testSet() { 
    ListIterator<String> iterator = create();
 
    assertTrue(iterator.hasNext());
    assertEquals("a", iterator.next());
    assertEquals("b", iterator.next());
    assertEquals("b", iterator.previous());
    try { 
      iterator.set("c");
      fail();
    } catch (UnsupportedOperationException expected) {}
  } 
 
  UnmodifiableListIterator<String> create() {
    final String[] array = {"a", "b", "c"};
 
    return new UnmodifiableListIterator<String>() {
      int i;
6
CodeRank

Related ListIterator next Questions & Answers:

next Method Overview
Returns the next element in the list and advances the cursor position.
See Code Examples for other Java 8 ListIterator Methods: