File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
src/com/codefortomorrow/advanced/chapter16/solutions Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ public LinkedListNode tail() {
53
53
LinkedListNode current = head ;
54
54
if (current == null ) return null ;
55
55
56
- while (current .getNext () != null ) {
56
+ while (current .next () != null ) {
57
57
current = current .next ();
58
58
}
59
59
@@ -68,7 +68,6 @@ public void add(int value) {
68
68
if (tail == null ) {
69
69
head = new LinkedListNode (value , null );
70
70
} else {
71
-
72
71
tail .setNext (new LinkedListNode (value , null ));
73
72
}
74
73
}
@@ -103,7 +102,7 @@ public String toString() {
103
102
if (current == null ) return null ;
104
103
do {
105
104
list += Integer .toString (current .value ()) + ", " ;
106
- current = current .getNext ();
105
+ current = current .next ();
107
106
} while (current != null );
108
107
109
108
// Remove trailing comma and space after last list element
@@ -139,4 +138,9 @@ public LinkedListNode(int value, LinkedListNode next) {
139
138
public LinkedListNode next () {
140
139
return this .next ;
141
140
}
141
+
142
+ public void setNext (LinkedListNode next ) {
143
+ this .next = next ;
144
+ return ;
145
+ }
142
146
}
You can’t perform that action at this time.
0 commit comments