We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
algo/java/06_linkedlist/SinglyLinkedList.java
Line 64 in b2c1228
//顺序插入 //链表尾部插入 public void insertTail(int value){ Node newNode = new Node(value, null); //空链表,可以插入新节点作为head,也可以不操作 if (head == null){ head = newNode; }else{ Node q = head; while(q.next != null){ q = q.next; } newNode.next = q.next; q.next = newNode; } }
只有q.next等于null才会跳出循环,newNode本身创建时的next已经是null了,这里将null赋值给newNode的next好像有点冗余,而且让人困惑。
The text was updated successfully, but these errors were encountered:
是的,我也有这个疑惑,不需要这个呢
Sorry, something went wrong.
No branches or pull requests
algo/java/06_linkedlist/SinglyLinkedList.java
Line 64 in b2c1228
只有q.next等于null才会跳出循环,newNode本身创建时的next已经是null了,这里将null赋值给newNode的next好像有点冗余,而且让人困惑。
The text was updated successfully, but these errors were encountered: