@Test public void rest() { { List<String> from = Arrays.asList("a", "b", "c"); SingleLinkedList<String> list = new SingleLinkedList<>(from); SingleLinkedList<String> rest = list.rest(); assertThat(rest.size(), is(2)); assertThat(rest.get(0), is("b")); assertThat(rest.get(1), is("c")); } { SingleLinkedList<String> list = new SingleLinkedList<>(); try { list.rest(); fail(); } catch (NoSuchElementException e) { } } }
public SingleLinkedList<E> rest() { if (isEmpty()) { throw new NoSuchElementException(); } return new SingleLinkedList<>(head.next); }
SingleLinkedList implements Iterable<E>, Serializable { public SingleLinkedList<E> rest() { if (isEmpty()) { throw new NoSuchElementException(); } return new SingleLinkedList<>(head.next); } }
SingleLinkedList implements Iterable<E>, Serializable { public SingleLinkedList<E> rest() { if (isEmpty()) { throw new NoSuchElementException(); } return new SingleLinkedList<>(head.next); } SingleLinkedList();  SingleLinkedList(List<? extends E> list);  SingleLinkedList(Iterable<? extends E> iterable); private  SingleLinkedList(Node<E> head); }
SingleLinkedList implements Iterable<E>, Serializable { public SingleLinkedList<E> rest() { if (isEmpty()) { throw new NoSuchElementException(); } return new SingleLinkedList<>(head.next); } SingleLinkedList();  SingleLinkedList(List<? extends E> list);  SingleLinkedList(Iterable<? extends E> iterable); private  SingleLinkedList(Node<E> head); boolean isEmpty(); int size(); SingleLinkedList<E> concat(E element); E first(); SingleLinkedList<E> rest(); E get(int index); @Override Iterator<E> iterator(); C fill(C target); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); }
SingleLinkedList implements Iterable<E>, Serializable { public SingleLinkedList<E> rest() { if (isEmpty()) { throw new NoSuchElementException(); } return new SingleLinkedList<>(head.next); } SingleLinkedList();  SingleLinkedList(List<? extends E> list);  SingleLinkedList(Iterable<? extends E> iterable); private  SingleLinkedList(Node<E> head); boolean isEmpty(); int size(); SingleLinkedList<E> concat(E element); E first(); SingleLinkedList<E> rest(); E get(int index); @Override Iterator<E> iterator(); C fill(C target); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }