ImmutableLinkedList extends AbstractSequentialList<T> { private ImmutableLinkedList() { head = null; tail = null; } private  ImmutableLinkedList();  ImmutableLinkedList(T head, ImmutableLinkedList<T> tail); @SuppressWarnings({"unchecked"}) static ImmutableLinkedList<T> nil(); T head(); ImmutableLinkedList<T> tail(); T last(); ImmutableLinkedList<T> prepend(T object); ImmutableLinkedList<T> reverse(); static boolean equal(ImmutableLinkedList<T> a, ImmutableLinkedList<T> b); static int hashCode(ImmutableLinkedList<?> list); @Override ListIterator<T> listIterator(int index); @Override boolean isEmpty(); @Override int size();  }
@Test public void testImmutableLinkedList() { assertEquals(nil().size(), 0); assertEquals(nil().prepend(5).size(), 1); assertEquals(nil().prepend(5).prepend(7).size(), 2); ImmutableLinkedList<Object> abc = nil().prepend("c").prepend("b").prepend("a"); assertEquals(StringUtils.join(abc, ","), "a,b,c"); assertEquals(StringUtils.join(abc.reverse(), ","), "c,b,a"); }