Skip to content

Commit d198578

Browse files
Merge pull request kunal-kushwaha#504 from Suvradippaul/patch-1
Corrected a null pointer exception
2 parents e9064ba + 34aef89 commit d198578

File tree

1 file changed

+3
-1
lines changed
  • lectures/18-linkedlist/code/src/com/kunal

1 file changed

+3
-1
lines changed

lectures/18-linkedlist/code/src/com/kunal/CLL.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ public void display() {
2828
if (head != null) {
2929
do {
3030
System.out.print(node.val + " -> ");
31-
node = node.next;
31+
if (node.next != null) {
32+
node = node.next;
33+
}
3234
} while (node != head);
3335
}
3436
System.out.println("HEAD");

0 commit comments

Comments
 (0)