リストの最初と最後にnullオブジェクトを含む二重リンクリストを作成しようとしていました。リストの最初と最後でnullオブジェクトとはどういう意味ですか。firstNode=nullとlastNode==nullを作成すると、この問題は解決しますか、それとも別の意味ですか?任意の提案をいただければ幸いです。
// Creating a doubly linked list.
doubleLinkedList = new DoubleLinkedList();
class DoubleLinkedList {
private NewLink firstNode;
private NewLink lastNode;
private NewLink rootNode;
// Initializing values in the Constructor for DoubleLinkedList
public DoubleLinkedList() {
rootNode = null;
firstNode = null;
lastNode = null;
}
}
class NewLink {
public String data;
public NewLink nextPointer;
public NewLink previousPointer;
public NewLink(String id) {
data = id;
}
// Overriding toString method to return the actual data of the node
public String toString() {
return "{" + data + "} ";
}
}