Hello,

I am attempting to reverse a linked list. I am using the algorithm stated in the blog article to reverse a linked List in Java, but I am not sure how to implement it in code.

The following is the algorithm:

1. Make a reference to the connected list's head node.
2. Make a reference to the preceding node.
3. Make the preceding node null.
4. As long as the current node is not null:
5. Set the previous node's next node to the current node.
6. Set the next node of the current node to the previous node.
7. Make the preceding node the current node.
8. Set the current node to the next node.
9. The preceding node will now be the inverted linked list's head.

I am not sure how to code steps three and four. Can somebody help?

Thanks!