Skip to content

Commit 90c9782

Browse files
committed
"Updated toString method to include brackets and removed default Node constructor."
1 parent 16cdb60 commit 90c9782

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/main/java/com/thealgorithms/datastructures/lists/SortedLinkedList.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,17 @@ public String toString() {
122122
elements.add(String.valueOf(temp.value));
123123
temp = temp.next;
124124
}
125-
return String.join(", ", elements);
125+
return "[" + String.join(", ", elements) + "]";
126+
126127
} else {
127-
return "";
128+
return "[]";
128129
}
129130
}
130131

131132
public final class Node {
132133
public final int value;
133134
public Node next;
134135

135-
public Node() {
136-
this.value = 0;
137-
this.next = null;
138-
}
139-
140136
public Node(int value) {
141137
this.value = value;
142138
this.next = null;

0 commit comments

Comments
 (0)