Site Search:

maze quiz 1

import java.util.Iterator;
public class MySet<Item> implements Iterator<Item> {
    private Node first;
    private class Node {
        private Item item;
        private Node next;
        public Node(Item item, Node next) {
            this.item = item;
            this.Node = next;
        }
    }
    public void add(Item item) {
        first = new Node(item, first);
    }
    public Iterator<Item> iterate {
        return new MyIterator();
    }
    private class MyIterator implements Iterator<Item> {
        Node current = first;
        public boolean hasNext() return current != null;
        public Item next() {
            Item item = current.item;
            //what is missing here?
            return item;
        }
    }
}