You are viewing a single comment's thread. Return to all comments →
@sarwarhayatt
What do you not understand?
This is a simple commented explanation of my code above:
void Print(Node head) {
while ( head != null) { //Iterate through the linked list until head is equal null (after last node)
System.out.println(head.data); //Display the value of the current node
head = head.next; //Move pointer to the next node
}
Seems like cookies are disabled on this browser, please enable them to open this website
Print the Elements of a Linked List
You are viewing a single comment's thread. Return to all comments →
@sarwarhayatt
What do you not understand?
This is a simple commented explanation of my code above:
void Print(Node head) {
while ( head != null) { //Iterate through the linked list until head is equal null (after last node)
System.out.println(head.data); //Display the value of the current node
head = head.next; //Move pointer to the next node
}