Give an implementation of the size() method for the singularly linked list class, assuming that we did not maintain size as an instance variable
public int size() {
Node<AnyType> tmp = head;
int size = 0;
if (head == null) {
return size;
} else {
size++;
while (tmp.next != null) {
tmp = tmp.next;
size++;
}
}
return size;
}