We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d82b458 commit c909d68Copy full SHA for c909d68
src/chapter03linkedlists/LinkedList.java
@@ -136,12 +136,16 @@ public synchronized void removeMatched(ListNode node) {
136
return;
137
if (node.equals(head)) {
138
head = head.getNext();
139
+ // reduce the length of the list
140
+ length-=1;
141
142
}
143
ListNode p = head, q = null;
144
while((q = p.getNext()) != null) {
145
if (node.equals(q)) {
146
p.setNext(q.getNext());
147
148
149
150
151
p = q;
0 commit comments