import java.util.Iterator; abstract class EnkelReseptListe implements Iterable { protected class Node { Node next; Resept val; Node(Resept val) { this.val = val; } } Node first; Node last; abstract public void settInn(Resept val); public Resept finn(int id) { Node n = first; while (n != null) { if (n.val.id == id) return n.val; n = n.next; } return null; } public Iterator iterator() { return new Iterator() { private Node n = first; public boolean hasNext() { return n != null; } public Resept next() { Resept r = n.val; n = n.next; return r; } }; } }