import java.util.*; class storagex { public void put(Object o) { data[nextEmptySlot++] = o; } public Object get() { return data[ --nextEmptySlot]; } private Object[] data = new Object[256]; // don’t allow access to anything not yet stored private int nextEmptySlot = 0; private int i=0; public Iterator iterator() { // returns a class that iterates over the data array return new Iterator() { // insert the body of the inner class here // 3 methods: remove(), hasNext(), next() public void remove() { return; } public boolean hasNext() { return true; } public Object next() { return new Object(); } }; } } public class storage { public static void main(String[] args) { storagex s = new storagex(); s.put(14); s.put(1955); s.put(new Integer(11)); Iterator i = s.iterator(); Object o = i.next(); } }