/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package iteratorexample;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.ListIterator;
/**
 *
 * @author Matthew
 */
public class IteratorExample {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        ArrayList<Double> myList = new ArrayList();
        
        myList.add(1.0);
        myList.add(2.0);
        myList.add(3.0);
        myList.add(4.0);
        myList.add(5.0);
        
        Iterator<Double> iterator = myList.iterator();
        
        while(iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        
        ListIterator<Double> editor = myList.listIterator();
        while(iterator.hasNext()) {
            
            editor.set(1.0);
            editor.next();
        }
        
        iterator = myList.iterator();
        
        while(iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        
    }
    
}
