Share via


ListIterator.next Method

Moves the iterator to the next element in the list.

Syntax

public void next()

Run On

Called

Remarks

Use the ListIterator.more method to determine whether the iterator points to a valid element.

Examples

The following example uses the ListIterator.next method to traverse a list as the value of each element is printed.

{ 
    List il = new List(Types::Integer); 
    ListIterator it; 
    int i; 
  
    // Add some elements 
    for (i = 1; i <= 10; i++) 
    { 
        il.addEnd(i); 
    } 
  
    // Traverse the list 
    it = new ListIterator(il); 
    while (it.more()) 
    { 
        print it.value(); 
        // Move to the next element 
        it.next();  
    } 
    pause; 
}

See Also

ListIterator Class

ListIterator.more Method

ListIterator.begin Method