@Test public void size() { { SingleLinkedList<String> list = new SingleLinkedList<>(); assertThat(list.size(), is(0)); } { List<String> from = Arrays.asList("a"); SingleLinkedList<String> list = new SingleLinkedList<>(from); assertThat(list.size(), is(1)); } { List<String> from = Arrays.asList("a", "b", "c"); SingleLinkedList<String> list = new SingleLinkedList<>(from); assertThat(list.size(), is(3)); } }
public int size() { int size = 0; for (Node<E> node = head; node != null; node = node.next) { size++; } return size; }
SingleLinkedList implements Iterable<E>, Serializable { public int size() { int size = 0; for (Node<E> node = head; node != null; node = node.next) { size++; } return size; } }
SingleLinkedList implements Iterable<E>, Serializable { public int size() { int size = 0; for (Node<E> node = head; node != null; node = node.next) { size++; } return size; } SingleLinkedList();  SingleLinkedList(List<? extends E> list);  SingleLinkedList(Iterable<? extends E> iterable); private  SingleLinkedList(Node<E> head); }
SingleLinkedList implements Iterable<E>, Serializable { public int size() { int size = 0; for (Node<E> node = head; node != null; node = node.next) { size++; } return size; } 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 int size() { int size = 0; for (Node<E> node = head; node != null; node = node.next) { size++; } return size; } 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();  }