Complete the code to move to the next node in the linked list.
current = current[1];To traverse a linked list, you move from the current node to the next node using the .next pointer.
Complete the code to print the data of the current node.
System.out.println(current[1]);The data stored in a node is accessed using the .data field.
Fix the error in the loop condition to traverse until the end of the list.
while (current [1] null) {
The loop should continue while current is not null, so use !=.
Fill both blanks to complete the loop that prints all nodes in the linked list.
while (current [1] null) { System.out.println(current[2]); current = current.next; }
The loop continues while current != null. Inside the loop, print current.data.
Fill all three blanks to create a method that prints all elements of a linked list.
public void printList(Node [1]) { Node current = [2]; while (current [3] null) { System.out.println(current.data); current = current.next; } }
The method takes the head node as a parameter, assigns it to current, and loops while current is not null.
