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() {
5353 LinkedListNode current = head ;
5454 if (current == null ) return null ;
5555
56- while (current .getNext () != null ) {
56+ while (current .next () != null ) {
5757 current = current .next ();
5858 }
5959
@@ -68,7 +68,6 @@ public void add(int value) {
6868 if (tail == null ) {
6969 head = new LinkedListNode (value , null );
7070 } else {
71-
7271 tail .setNext (new LinkedListNode (value , null ));
7372 }
7473 }
@@ -103,7 +102,7 @@ public String toString() {
103102 if (current == null ) return null ;
104103 do {
105104 list += Integer .toString (current .value ()) + ", " ;
106- current = current .getNext ();
105+ current = current .next ();
107106 } while (current != null );
108107
109108 // Remove trailing comma and space after last list element
@@ -139,4 +138,9 @@ public LinkedListNode(int value, LinkedListNode next) {
139138 public LinkedListNode next () {
140139 return this .next ;
141140 }
141+
142+ public void setNext (LinkedListNode next ) {
143+ this .next = next ;
144+ return ;
145+ }
142146}
You can’t perform that action at this time.
0 commit comments