In my CS class we just started working with linked lists. The book goes into PAINFUL EXCRUCIATING LONG WINDED VOLUMINOUS detail about what a linked list is (which all could be summarized in a few sentences), spits out a couple code snippets and expects me to put it together. I'm having a really difficult time with it.
I can't even create a node. From my main I created an instance of the following, and everything is fine until I try I get to tom.next = dick.
I'm just missing something, it keeps saying type expected. Any Linked List guidance would be greatlyu appreciated.
import java.util.*; public class SingleLinkedList<E> { Node<String> tom = new Node<String>("Tom"); Node<String> dick = new Node<String>("Dick"); Node<String> harry = new Node<String>("Harry"); tom.next = dick; //This is throwing up dick.next = harry; //and this line as well private static class Node<E> { //Data Fields //Reference to the data private E data; //Reference to the next node private Node<E> next; //Constructors //Creates new node with a null next field private Node(E dataItem) { data = dataItem; next = null; } //Creats a new node that references another node private Node(E dataItem, Node<E> nodeRef) { data = dataItem; next = nodeRef; } } }