dimanche 28 septembre 2014

doublylinkedlist creating node


Vote count:

0




I am working on a assignment in java that uses a generic type doubly linked lists. I'm sure this is a basic question but since I could not find the answer I thought I would ask. Essentially the implementation of the doubly linked list class is given and all I am required to do is create some nodes. The problem I am having is that the node class is a private static nested class in the list class and I do not understand how I should be using it. The list class looks something like this (leaving out several get and set methods):



public class LinkedList<E> {

private static class Node<E>{
private E element;
private Node<E> previous;
private Node<E> next;

public Node(E e, Node<E> p, Node<E> n) {
element = e;
prev = p;
next = n;
}

}
}


In my driver class I use this:



LinkedList <String> linkedlist = new DoublyLinkedList<String>();
LinkedList.Node node = linkedlist.new Node();

node n1 = new node("Amy", null);


Using this I get an error saying that LinkedList.Node should be changed to default visibility. Any help is appreciated.



asked 32 secs ago







doublylinkedlist creating node

Aucun commentaire:

Enregistrer un commentaire