我现在正在学习Java,我想按字母顺序对双向链表进行排序,并让用户输入一个字母或单词。有人可以帮我吗?
这是我到目前为止的代码。
public class DoublyLinkedList {
String data;
Node next;
Node prev;
Node head;
public void Node(String data, Node next, Node prev, Node head) {
this.data = data;
this.next = next;
this.prev = prev;
this.head = head;
}
//inserts new Node at front of the list.
public void push(String newData) {
Node newNode = new Node(newData);
newNode.next = head;
head = newNode;
}
}