今天第二次java上機,被老師問得一臉懵逼,看似很容易解讀的代碼,其深層含義卻無法回答。問題的關鍵是對象以及對象的引用,代碼片段如下
node tail,head; lianbiao(){ head = new node(1); tail = head; } void Headin(int x){ node p = new node(x); if(head.next==null){ tail=p; } p.next=head.next; head.next=p; }被問到node head ,tail以及node p = new code(x)的機制??粗苋菀鬃砸詾槭?,實際上機制并非想當然。這邊給一張圖解
應該很清楚
新聞熱點
疑難解答