University of Toronto
Department of Computer Science
csc 148: Introduction to Computer Science

Linked Data Structures (continued)

Step 3: Creating a new node

Before we can insert a value into the list, we need a node to put it in. Suppose we have the following code in our method already:
       Node temp;
       temp = new Node();
Write a Java statement to store in that new node the integer value to be inserted in the linked list.

Now the picture looks like this:


Step 4: Inserting the new node

What code will hook the new node in properly?

Click here to go to the next step. 


PreviousPrevious    |   Home   |   Next Next