无法理解Java双向链表

无法理解Java双向链表

本文介绍了无法理解Java双向链表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码

  public class Doublylinkedlist {
private DLLNode head;
私有DLLNode尾;
private int length;
}

这是什么 DLLNode

这里是DLLNode类

 公开类DLLNode {
private int data;
private DLLNode prev;
private DLLNode next;

}



私有DLLNode prev'?
它是什么数据类型?

解决方案

DLLNode是一个用户定义的类,就像您的Doublylinkedlist类一样。 >

该DLLNode类可能是一个可能的例子:

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

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


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 ?

解决方案

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;
    }
}

这篇关于无法理解Java双向链表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 19:06