Implementing list using linked list Implementing list using
Implementing list using linked list
Implementing list using linked list size java.lang.Integer size() Determine the size of this list. Returns: the number of elements in this listSolution
Below is the size() method for LinkedList
public class LinkedList
{ //Start of LinkedList class
private Node first;
public LinkedList()
{
first = null;
}
public Integer size()
{
int s = 0;
Node current = first;
while(current!=null)
{
s++;
current = current.next;
}
return s;
}
}
