Can't understand Java doubly linked list [closed]

孤街醉人 提交于 2019-12-14 04:24:02

问题


I have this code

public class Doublylinkedlist {
    private DLLNode head;
    private DLLNode tail;
    private int length;
}

What is this DLLNode head declaration? What data type it is? Can someone please explain?

Here is the DLLNode class

Public class DLLNode{
private int data ;
private DLLNode prev;
private DLLNode next;

}

Now what is this 'private DLLNode prev'? What data type it is ?


回答1:


DLLNode is a user defined class just like your Doublylinkedlist class.

A possible example of what that DLLNode class might look like:

public class DLLNode
{
    int data;
    DLLNode next;
    DLLNode prev;

    public DLLNode(int data)
    {
        this.data = data;
        this.next = null;
        this.prev = null;
    }
}


来源:https://stackoverflow.com/questions/35533868/cant-understand-java-doubly-linked-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!