public CharList(CharList l)
{
// Whatever method your CharList provides to get the
// first node in the list goes here
CharNode pt = l.head();
// create a new head node for *this* list
CharNode newNode = new CharNode();
this.head = newNode;
// Go through old list, copy data, create new nodes
// for this list.
while(pt != null)
{
newNode.setCharacter(pt.getCharacter());
pt = pt.getNext();
if (pt != null)
{
newNode.setNext(new CharNode());
newNode = newNode.getNext();
}
}
}
我認爲這是用來引用對象A中的「A.addElement(car);」,但在這種情況下我不知道這是指什麼......而且我不看到在做點:this.head = newNode;因爲這個頭不再被使用。「this」在這段代碼中究竟是指什麼?
可能的重複[在java中使用關鍵字「this」](http://stackoverflow.com/questions/577575/using-the-keyword-this-in-java) – CoolBeans
這條線沒有意義: newNode = newNode.getNext();它應該是newNode = pt; – user2089523