你如何遍历链表的末尾?

时间:2016-05-04 15:48:38

标签: java

有人能解释一下

是什么吗?
current = current.getnext();

从下面的代码中真正意味着什么?

public void add(Object data)
// post: appends the specified element to the end of this list.
{
    Node temp = new Node(data);
    Node current = head;
    // starting at the head node, crawl to the end of the list
    while(current.getNext() != null)
    {
        current = current.getNext();
    }
    // the last node's "next" reference set to our new node
    current.setNext(temp);
    listCount++;// increment the number of elements variable
}

0 个答案:

没有答案