/*
 * 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 lliterator;

import java.util.*;
/**
 *
 * @author Matthew
 */
public class LLIterator {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        LinkedList<Integer> myList = new LinkedList();
        //ArrayList<Integer> myList = new ArrayList();
        myList.add(1);
        myList.add(2);
        myList.add(3);
        myList.add(4);
        myList.add(5);
        
        Iterator itr = myList.iterator();
        
        while(itr.hasNext()) {
            if(itr.next().equals(4)) {
                itr.remove();
            }
        }
        
        itr = myList.iterator();
        while(itr.hasNext()) {
            System.out.print(itr.next()+" ");
        }
    
    }
    
}
