You are viewing a single comment's thread. Return to all comments →
In the 3rd line you return a new Node object. I thought we were supposed to return only the head object. Can you explain this part? My understanding with linked list is that the head never has any data but is used to reference the first element in the list, yet you return a single Node with data and no head.
I can explain. The third line return the newest Node as the inserted node to the linked list because the program has already checked the head is Null. Returning the newest node would be the answer