001package headfirst.iterator.dinermerger; 002 003import java.util.ArrayList; 004 005@SuppressWarnings("rawtypes") 006public class ArrayListIterator implements Iterator { 007 ArrayList items; 008 int position = 0; 009 010 public ArrayListIterator(ArrayList items) { 011 this.items = items; 012 } 013 014 public Object next() { 015 Object object = items.get(position); 016 position = position + 1; 017 return object; 018 } 019 020 public boolean hasNext() { 021 if (position >= items.size()) { 022 return false; 023 } else { 024 return true; 025 } 026 } 027}