我想实现一种方法,该方法将整数和链接作为输入,并将链接插入到 LinkedList 中的链接位置输入整数之前,我已经实现了:
public void insertBefore(int num, String data)
{
Link current = head;
int count = 0;
while (current.next != null)
{
if(count == num) {
Link n = new Link(data);
n.next = current;
current.next = n.previous;
}
}
current = current.next;
count++;
}
但是,当我调用该方法时,什么也没有发生,也没有插入链接,所以有人知道该方法的问题吗?