Skip to content

Commit 49a150f

Browse files
Fix example implementation for linked-list after extra tests were added (exercism#2344)
1 parent cdb28e9 commit 49a150f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

exercises/practice/linked-list/.meta/src/reference/java/DoublyLinkedList.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ void push(T value) {
1616
}
1717

1818
T pop() {
19+
if (head == null) {
20+
return null;
21+
}
22+
1923
head = head.prev;
2024
return shift();
2125
}
@@ -26,6 +30,10 @@ void unshift(T value) {
2630
}
2731

2832
T shift() {
33+
if (head == null) {
34+
return null;
35+
}
36+
2937
T value = head.value;
3038

3139
Element<T> newHead = head.next;

0 commit comments

Comments
 (0)