public class LinkedList implements List { private Node head = null; private int size = 0; private static class Node { private T value; private Node next; private Node( T value, Node next ) { this.value = value; this.next = next; } } private class LinkedListIterator implements Iterator { private Node current; public boolean hasNext() { return ( ( (current == null) && (head != null) ) || ( (current != null) && (current.next != null) ) ); } public E next() { if ( current == null ) { current = head; } else { current = current.next; } return current.value; } } public Iterator iterator() { return new LinkedListIterator(); } public int size() { return size; } public E get( int pos ) { if ( pos < 0 || pos >= size ) { throw new IndexOutOfBoundsException( Integer.toString(pos) ); } E result; Node p = head; for (int i=0; i(e, head); size++; } public void test() { Node p = head; while (p != null) { E o = p.value; p = p.next; } } }