deadpixels
deadpixels

Reputation: 819

Doubly linked list object error

I am trying to create a double linked list sequence which contains objects and I get an error while implementing it:

  protected class Node {

    public Node(Object o) {
        prev = null;
        next = null;
        this(o, null);

    }

    public Node(Object o, Node next, Node prev) {
        this.next = next;
        this.prev = prev;
        datum = o;
    }

    protected Object datum;
    protected Node next;
    protected Node prev;


}

The problem is at the this(o.null); line where is says that the program "cannot resolve this method". Any ideas please?

Upvotes: 2

Views: 52

Answers (2)

Marc Baumbach
Marc Baumbach

Reputation: 10473

You don't have a constructor that takes two arguments. Your one argument constructor should probably look like:

public Node(Object o) {
    this(o, null, null);
}

Upvotes: 1

DennisW
DennisW

Reputation: 1057

It should be this(o, null, null);, as you don't have a constructor which takes two arguments. Also, this must be the first statement in the constructor, which also means you won't need the other two lines.

Upvotes: 1

Related Questions