Question: Assuming head refers to the first node in a non-empty chain of nodes, which of the following code snippets will print all the data in
Assuming head refers to the first node in a non-empty chain of nodes, which of the following code snippets will print all the data in the nodes without crashing. Node curr = head; while (curr != null) \{ System. out.println(curr. data); curr = curr. next; \} ( Node curr = head; while (curr. next != null) \{ System. out.println(curr. data); curr = curr. next; Node curr = head; while (curr. data != null) \{ System. out.println(curr.data); curr = curr. next; 3 Node curr = head; while (curr != null) \{ curr = curr. next; } System. out.println(curr.data)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
