go to previous page   go to home page   go to next page

Answer:

Yes. In this case the headPtr is null.

This is how LinkedList looks just after construction.


Empty List

empty linked list

A linked list without any nodes is called empty. However, the LinkedList object still exists. Here is a tester method for the LinkedList class that creates an empty list:

public class LinkedListTester
{
  public static void main( String[] args )
  {
    // create an empty linked list
    LinkedList list = new LinkedList();  
  }
}

After an empty list has been created, nodes can be linked into a chain using list.insertFirst() .


QUESTION 3:

Complete the isEmpty() method of LinkedList .

  // Determine if the List is empty
  public boolean isEmpty()
  {
     // return true for an empty list
  }

go to previous page   go to home page   go to next page